How to fast get Hardware-ID in C#?

For more details refer to this link The following code will give you CPU ID: namespace required System.Management var mbs = new ManagementObjectSearcher(“Select ProcessorId From Win32_processor”); ManagementObjectCollection mbsList = mbs.Get(); string id = “”; foreach (ManagementObject mo in mbsList) { id = mo[“ProcessorId”].ToString(); break; } For Hard disk ID and motherboard id details refer this-link … Read more

How do I check CPU and Memory Usage in Java?

If you are looking specifically for memory in JVM: Runtime runtime = Runtime.getRuntime(); NumberFormat format = NumberFormat.getInstance(); StringBuilder sb = new StringBuilder(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); sb.append(“free memory: ” + format.format(freeMemory / 1024) + “<br/>”); sb.append(“allocated memory: ” + format.format(allocatedMemory / 1024) + “<br/>”); sb.append(“max memory: ” … Read more

How can I measure CPU time and wall clock time on both Linux/Windows?

Here’s a copy-paste solution that works on both Windows and Linux as well as C and C++. As mentioned in the comments, there’s a boost library that does this. But if you can’t use boost, this should work: // Windows #ifdef _WIN32 #include <Windows.h> double get_wall_time(){ LARGE_INTEGER time,freq; if (!QueryPerformanceFrequency(&freq)){ // Handle error return 0; … Read more