模拟处理器的(有限)资源,包括时钟速度

发布于 2024-10-03 18:47:04 字数 175 浏览 4 评论 0原文

我想要一个软件环境,在其中我可以在具有特定资源的硬件上测试软件的速度。例如,当我的主机硬件是具有 12GB RAM 的 3GHz 四核 amd64 时,该程序在具有 24 Mb RAM 的 800MHz x86 上运行速度有多快? qemu 等模拟器的一大特色是与底层硬件“几乎一样快”地运行;我想让它运行得慢一些。有办法做到这一点吗?

I would like a software environment in which I can test the speed of my software on hardware with specific resources. For example, how fast does this program run on an 800MHz x86 with 24 Mb of RAM, when my host hardware is a 3GHz quad core amd64 with 12GB of RAM? Emulators such as qemu make a great point of running "almost as fast" as the underlying hardware; I would like to make it run slower. Is there a way to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮茶煮酒煮时光 2024-10-10 18:47:04

我从未尝试过,但也许您可以通过将 Linux 上的 QEMU 或 VirtualBox 等模拟器与类似这样的东西相结合来在某种程度上实现您想要的目标:

http://cpulimit.sourceforge.net/

如果您可以限制模拟器可用的 CPU 时间,您也许能够在速度较慢的计算机上模拟执行结果。但请记住,这只会影响执行速度(至少我希望如此)。

CPU指令集和其他系统功能将保持不变。这意味着准确地模拟特定处理器即使不是不可能,也是很困难的。

此外,使用诸如 cpulimit 之类的东西(它使用 SIGSTOP 和 SIGCONT 来重复停止/重新启动模拟器进程)可能会导致副作用,例如时序不一致、视频显示伪影等。

I have never tried it, but perhaps you could achieve what you want to some extent by combining an emulator like QEMU or VirtualBox on Linux with something like this:

http://cpulimit.sourceforge.net/

If you can limit the CPU time available to the emulator you might be able to simulate the results of execution on a slower computer. Keep in mind, though, that this would only affect the execution speed (or so I hope, anyway).

The CPU instruction set and other system features would remain unchanged. This means that emulating a specific processor accurately would be difficult if not impossible.

In addition, using something like cpulimit, which works using SIGSTOP and SIGCONT to repeatedly stop/restart the emulator process might cause side-effects, such as timing inconsistencies, video display artifacts etc.

软糖 2024-10-10 18:47:04

在您的模拟器中,保留一个虚拟“时钟”并在执行每条指令时适当增加它。从那里,您可以简单地报告执行所需的虚拟时间多长时间,或者您可以让模拟器时不时地休眠,以将执行速度大致保持在目标中的速度。

In your emulator, keep a virtual "clock" and increment it appropriately as you execute each instruction. From there you can simply report how long it took in virtual time to execute, or you can have your emulator sleep now and again to keep execution speed roughly where it would be in the target.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文