用于了解我的程序是仅使用一个 CPU 还是在多处理器计算机中使用多个 CPU 的命令
有没有命令可以知道我的程序是仅使用一个处理器还是多个处理器?
我的程序不是多线程的,因此我的程序一次只使用一个 CPU,但可能会不时地在 CPU 之间进行切换。
我可以看到我的程序的切换顺序吗?有命令吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Windows 上,任务管理器显示单个处理器/内核的利用率。如果从一个核心切换到另一个核心,您应该能够将其视为图表上的下降,而另一个核心的活动同时上升。
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.
如果您使用的是 Windows,并且可以重新编译程序,则可以使用
GetCurrentProcessorNumber
API 函数。但请注意,这会告诉您执行此函数时您所在的处理器,但当然,当函数返回并且您可以读取答案时,您可能正在不同的处理器上运行。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