开发者

Command to know whether my program is using only one CPU or multiple CPUs in a multiple processor machine

开发者 https://www.devze.com 2023-02-26 11:45 出处:网络
Is there any command to know whether my program is using only one processor or multiple processors? My program is not multi-threaded, so at a time only one CPU is being used by my program, but time

Is there any command to know whether my program is using only one processor or multiple processors?

My program is not multi-threaded, so at a time only one CPU is being used by my program, but time to time switching between the CPU's can happen.

Can I see this switching sequence for my开发者_运维技巧 program? Is there any command?


On Windows the Task Manager shows utilization of the single processors/cores. If there is switching from one core to another going on you should be able to see it as a drop in on graph with a simultaneous rise of activity in another.


If you're on Windows, and if you can recompile your program, you can use the GetCurrentProcessorNumber API function. Note, however, that this tells you which processor you were on at the time this function was executed, but of course by the time the function returns and you can read the answer, you might be running on a different processor.


I think this thread would answer your question, Programmatically find the number of cores on a machine

0

精彩评论

暂无评论...
验证码 换一张
取 消