cpu

Using OperatingSystemMXBean to get CPU usage

橙三吉。 提交于 2019-11-29 06:22:08
I'm trying to use Java to get the percentage of CPU used by the currently running Java Virtual Machine. My research has pointed me to using the com.sun.management.OperatingSystemMXBean class. Following examples online, I've written the following: import java.lang.management.ManagementFactory; import com.sun.management.OperatingSystemMXBean; public class TestClass { public static void main (String[] args) { OperatingSystemMXBean bean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); System.out.println(bean.getProcessCpuLoad()); System.out.println(bean

How to restrict the CPU usage a C# program takes?

回眸只為那壹抹淺笑 提交于 2019-11-29 06:17:29
I am developing a C# program, and i have one function that consumes too much CPU. I would like to know a way to control this by code (not with any external application) and restrict the percentage of CPU usage. For example, if it uses 90% of the CPU usage, to make my app consume only a 20%, even if it becomes slower. It must be done automatically and from within the app. If you provide a class, it would be fantastic. I don't know if you can do that, but you can change the thread priority of the executing thread via the Priority property. You would set that by: Thread.CurrentThread.Priority =

Xcode 4.3.2 and 100% CPU constantly in the idle time

纵饮孤独 提交于 2019-11-29 06:15:35
My Xcode started to behave very heavily from yesterday when working on medium size project (around 200 source files). Project compiles correctly and runs in both simulator and device. I do not use any 3rd party libraries, except few widely used includes (like JSON or facebook ios sdk). It constantly uses CPU(s) at full speed, even if it is in idle state (no indexing, no compiling, no editing). The usage of RAM is relatively normal (300-50MB). My machine uses: Core 2 Duo 3.04Ghz CPU, 8GB of RAM and Vertex OCZ 3 SSD drive. I have tried every suggested solution found at stackoverflow: Cleaned

Profile specific animation CPU

这一生的挚爱 提交于 2019-11-29 05:10:02
问题 The situation & problem I have multiple animations (css and javascript/jQuery) in my site and sometimes it makes my site stutter. My question How can I see how much cpu a specific animation (both CSS, JavaScript and jQuery) uses in runtime and execution time I know how I can see the entire site CPU usage but not for a specific animation. 回答1: Click F12, Go to profiles, click on start. Reload page. Wait untill your page reloaded, and click stop. Click on your profile and see result (Y) 回答2:

Feasibility of GPU as a CPU? [closed]

放肆的年华 提交于 2019-11-29 03:43:05
What do you think the future of GPU as a CPU initiatives like CUDA are? Do you think they are going to become mainstream and be the next adopted fad in the industry? Apple is building a new framework for using the GPU to do CPU tasks and there has been alot of success in the Nvidias CUDA project in the sciences. Would you suggest that a student commit time into this field? Mo. First of all I don't think this questions really belongs on SO. In my opinion the GPU is a very interesting alternative whenever you do vector-based float mathematics. However this translates to: It will not become

Why are 50 threads faster than 4?

孤街醉人 提交于 2019-11-29 02:00:08
问题 DWORD WINAPI MyThreadFunction(LPVOID lpParam) { volatile auto x = 1; for (auto i = 0; i < 800000000 / MAX_THREADS; ++i) { x += i / 3; } return 0; } This function is run in MAX_THREADS threads. I have run the tests on Intel Core 2 Duo , Windows 7 , MS Visual Studio 2012 using Concurrency Visualizer with MAX_THREADS=4 and MAX_THREADS=50 . test1 (4 threads) completed in 7.1 seconds , but test2 (50 threads) completed in 5.8 seconds while test1 has more context switches than test2 . I have run the

How to get CPU temperature in Android

瘦欲@ 提交于 2019-11-29 01:49:13
Sensor Type TYPE_TEMPERATURE has been deprecated [since Android 2.3] probably which was giving info about CPU temperature. Now we have Sensor Type TYPE_AMBIENT_TEMPERATURE which will provide us room temperature (none of my use, & btw not all devices&/Android versions support it) I checked few apps which measures CPU temperature. Probably they're reading system files. I tried locating, in some devices I'm able to locate it inside following path: sys/devices/virtual/thermal/thermal_zone0/temp The structure bit varies from vendor to vendor & also the unit of measurement. fine! But in many devices

Why does this Java code not utilize all CPU cores?

人盡茶涼 提交于 2019-11-29 01:32:28
The attached simple Java code should load all available cpu core when starting it with the right parameters. So for instance, you start it with java VMTest 8 int 0 and it will start 8 threads that do nothing else than looping and adding 2 to an integer. Something that runs in registers and not even allocates new memory. The problem we are facing now is, that we do not get a 24 core machine loaded (AMD 2 sockets with 12 cores each), when running this simple program (with 24 threads of course). Similar things happen with 2 programs each 12 threads or smaller machines. So our suspicion is that

Execute RDMSR and WRMSR instructions from C/C++ code

こ雲淡風輕ζ 提交于 2019-11-29 00:45:10
I need to control C-State configuration. Specifically, I'd probably like to execute the following asm code: __asm { rdmsr and eax, 0x00 or eax, 0x01 wrmsr } Currently, I got this exception on rdmsr line: Unhandled exception at 0x00e3139e in MessWithCStates.exe: 0xC0000096: Privileged instruction. How can I (permanently) elevate priviliges of my app so it could execute the code above? I use VS 2010. NOTE: It is possible without writing a kernel-mode driver. See R/W Everything . Chances are, you are running this code on an x86 processor within Ring 3. You do not have the privileges to execute

How to get CPU frequency in c#

我们两清 提交于 2019-11-28 23:56:08
How can I get in c# the CPU frequency (example : 2Ghz) ? It's simple but I don't find it in the environnement variables. Thanks :) var searcher = new ManagementObjectSearcher( "select MaxClockSpeed from Win32_Processor"); foreach (var item in searcher.Get()) { var clockSpeed = (uint)item["MaxClockSpeed"]; } if you wish to get other fields look at class Win32_processor Try this code using System.Management; uint currentsp , Maxsp; public void CPUSpeed() { using(ManagementObject Mo = new ManagementObject("Win32_Processor.DeviceID='CPU0'")) { currentsp = (uint)(Mo["CurrentClockSpeed"]); Maxsp =