是否可以强制现有的Java应用程序使用不超过x个内核? [英] Is it possible to force an existing Java application to use no more than x cores?

查看:146
本文介绍了是否可以强制现有的Java应用程序使用不超过x个内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在对现有的Java程序进行基准测试。它们是旨在从多核CPU中受益的线程应用程序。我们想测量核心数量对运行速度的影响,但我们不愿意(也无法)更改这些应用程序的代码。

We are benchmarking existing Java programs. They are threaded applications designed to benefit from multi-core CPUs. We would like to measure the effect of the number of cores on the running speed, but we are unwilling (and unable) to change the code of these applications.

当然,我们可以在不同的机器上测试软件,但这样既昂贵又复杂。我们宁愿拥有一个软件解决方案。

Of course, we could test the software on different machines, but this is expensive and complicated. We would rather have a software solution.

注意:您可以假设测试平台是Windows,Linux或Mac。理想情况下,我们希望能够在两个平台上运行测试。

Note: you can assume that the testing platform is either Windows, Linux or Mac. Ideally, we would like to be able to run the tests on either of these platforms.

推荐答案

这就是所谓的设置CPU的亲和力,和它是流程的操作系统设置,不是特定于Java的。

It's called setting CPU affinity, and it's an OS setting for processes, not specific to Java.

在Linux上: http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html

在Windows上: http://www.addictivetips.com/windows-tips/how-to-set-processor-affinity-to-an-application-in-windows/

On Windows: http://www.addictivetips.com/windows-tips/how-to-set-processor-affinity-to-an-application-in-windows/

在Mac上看起来不像你可以设置它: https://superuser.com/questions/149312/how-to-set-processor-affinity-on-os-x

On Mac it doesn't look like you can set it: https://superuser.com/questions/149312/how-to-set-processor-affinity-on-os-x

这篇关于是否可以强制现有的Java应用程序使用不超过x个内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆