如何模拟较低 CPU 处理器的机器进行浏览器测试
我们有一些用户使用 CPU 功率较低的机器,他们在使用我们的 Web 应用程序时遇到响应时间缓慢的问题。有什么方法可以让我进行测试,以便模拟较低的 CPU 速率吗?
例如,我有 2.3 Ghz 的计算能力,我可以将其降低到 1.6 Ghz 或更低,以便我可以测试它吗?
顺便说一句,我们的客户正在使用 Windows。我必须在 Internet Explorer 作为浏览器上模拟低计算能力。
We have some users which are using lower-CPU powered machines and they're encountering slow response times using our web application. Is there any way for me to do testing so that I can simulate lower CPU rates?
For example, I have 2.3 Ghz computing power, can I lower it to 1.6 Ghz or lower so that I may be able to test it?
BTW, our customers are using Windows. I have to simulate low computing power on Internet Explorer as browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
大多数新的 CPU 乘数都可以轻松降低(Intel:Speedstep,AMD:PowerNow!)。这是为了节省电力。使用 RMclock,您可以手动调整乘数,从而降低频率并使您的电脑变慢。我自己使用这个工具,所以我可以告诉你它是有效的。
http://cpu.rightmark.org/products/rmclock.shtml
Most new CPUs multiplier can easily be lowered (Intel: Speedstep, AMD: PowerNow!). This is used to save power. With RMclock you can manually adjust your multiplier and thus lower your frequency and make your pc slower. I use this tool myself so I can tell you that it works.
http://cpu.rightmark.org/products/rmclock.shtml
虚拟机 Bochs(读作box)允许您设置
每秒指令数
指令。它可能是目前最慢的模拟器......The virtual machine Bochs(pronounced boxes) allows you to set a
instructions per second
directive. It's probably the slowest emulator out there as it is though...创建一些虚拟机。
您可以使用 VirtualPC 或 VirtualBox 两者都是免费的。
Create some virtual machines.
You can use VirtualPC or VirtualBox both are free.
我建议在后台启动一些会耗尽所有处理器周期的东西。
查找素数或类似内容的程序。
I would recommend to start something on the background which eats up all your processor cycles.
A program which finds primenumbers or something similar.
除了上述选项之外,另一个小选项是以较低的资源配置启动 Windows。转到开始菜单,选择运行并键入 MSCONFIG。您可以转到启动选项卡,单击高级选项并限制内存和处理器数量。它不像上面那样强大,但它确实为您提供了另一种选择。
Another slight option in addition to those above is to boot windows in a lower resource config. Go to the start menu,, select run and type MSCONFIG. You can go to the boot tab, click on advanced options and limit the memory and number of of processsors. It's not as robust as the above, but it does give you another option.
降低 CPU 时钟并不总能带来预期的结果。
较新的 CPU 具有架构改进功能,这使得它们在同等时钟基础上比旧芯片更加高效。顺便说一句,因此虚拟机对于测试“旧”技术的性能来说也是一种不好的方法。
最好的选择是简单地购买几台旧机器。使用类似的 RAM(类型和数量)、处理器、主板芯片组、硬盘驱动器和显卡。所有这些都会影响机器本身的总体性能。
我提出了其他组件,因为仅更改其中一个组件就会对浏览器性能产生影响。一个典型的例子是记忆。如果您的客户端仅限于 512MB RAM,则计算机可能会执行大量硬盘驱动器访问以进行 VM 交换,即使只是运行浏览器也是如此。在这种情况下,即使其他条件都相同,降低处理器的时钟速度同时仍保留 2GB(假设)RAM 的性能仍然不会接近相同。
Lowering the CPU clock doesn't always give expected results.
Newer CPUs feature architecture improvements which make them more efficient on an equvialent clock basis than older chips. Incidentally, because of this virtual machines are a bad way of testing performance for "older" tech as well.
Your best bet is to simply buy a couple of older machines. Using similar RAM (types and amounts), processor, motherboard chipsets, hard drives, and video cards. All of which feed into the total performance of the machine itself.
I bring the other components up because changing just one of them can have an impact on even browser performance. A prime example is memory. If your clients are constrained to something like 512MB of RAM, the machines could be performing a lot of hard drive access for VM swaps, even for just running the browser. In this situation downgrading the clock speed on your processor while still retaining your 2GB (assuming) of RAM would still not perform anywhere near the same even if everything else was equal.
Isak Savo 的答案有效,但可能有点挑剔,因为现代 tpl 将尝试限制 CPU 负载尽可能。当我对其进行测试时,很难(尽管通过一些测试是可能的)始终如一地获得我想要的 cpu 使用类型。
然后我想起来,http://www.cpukiller.com/,它已经做到了这一点。强烈推荐。顺便说一句,我在现代机器上玩 90 年代的旧游戏时发现了这个实用程序,当时帧速率与 CPU 时钟时间挂钩,使得在现代计算机上玩它们太快了。很有用。
Isak Savo'sanswer works, but can be a bit finicky, as the modern tpl is going to try and limit cpu load as much as possible. When I tested it out, It was hard (though possible with some testing) to consistently get the types of cpu usages I wanted.
Then I remembered, http://www.cpukiller.com/, which does this already. Highly recommended. As an aside, I found this util from playing old 90s games on modern machines, back when frame rate was pegged to cpu clock time, making playing them on modern computers way too fast. Great utility.
高性能和低性能 CPU 之间的另一个大区别是可用内核的数量。实际上,这可能相差 4 倍,远远超过您可能遇到的时钟频率的差异。
您可以通过设置线程亲和性来解决这个问题。即使 IE6 也会使用 13 个线程来显示 google.com。这意味着它将受益于多核CPU。但如果您仅将线程亲和性设置为一个核心,则所有 13 个 IE 线程将必须共享该一个核心。
Another big difference between high-performance and low-performance CPUs is the number of cores available. This can realistically differ by a factor of 4, way more than the difference in clock frequency you're likely to encounter.
You can solve this by setting the thread affinity. Even IE6 will use 13 threads just to show google.com. That means it will benefit from a multi-core CPU. But if you set the thread affinity to one core only, all 13 IE threads will have to share that one core.
我知道这个问题已经很老了,但这里有一些我个人使用的收据(不仅用于 Web 开发):
转至控制面板\所有控制面板项目\电源选项\编辑计划设置\更改高级电源设置,然后转至“处理器”部分并设置其最大状态为 5%(或其他)。仅当您的处理器支持动态乘数更改并且正确安装了 ACPI 驱动程序时,它才有效。
运行任务管理器并将处理器关联设置为浏览器(或任何其他)进程的单个核心(或您想要的任何数量的核心)。对于浏览器来说这不是最佳实践,因为 JavaScript 实现通常是单线程的,但是据我所知,现代浏览器实际上确实使用了多个内核。
I understand that this question is pretty old, but here are some receipts I personally use (not only for Web development):
BES. I'm getting some weird results while using it.
Go to Control Panel\All Control Panel Items\Power Options\Edit Plan Settings\Change Advanced Power Settings, then go to the "Processor" section and set it's maximum state to 5% (or something else). It works only if your processor supports dynamic multiplier change and ACPI driver is installed correctly.
Run Task Manager and set processor affinity to a single core (or whatever number of cores you want) for your browser's (or any other's) process. Not a best practice for browsers, because JavaScript implementations are usually single-threaded, but, as far as I see, modern browsers actually DO use multiple cores.
有几种不同的方法可以实现这一点。
如果您使用的是 VirtualBox,请进入您想要降低 CPU 速度的虚拟机的“设置”。转到系统>处理器,然后设置执行上限。百分比控制速度的慢速:相对于常规速度,较低的值较慢。在实践中,我注意到结果不稳定,尽管它在技术上确实有效。
还可以设置整个系统的 CPU 速度。在 Windows 10 设置应用程序中,转到系统 >电源与睡觉。然后单击右侧的其他电源设置。转到当前所选计划的更改计划设置,然后单击更改高级电源计划设置。向下滚动到处理器电源管理并设置最大处理器状态。再次强调,这是一个百分比。虽然这确实有效,但我发现在实践中,即使百分比设置得很低,也不会产生很大的影响。
如果您正在处理使用 DirectX 或 OpenGL 并且没有帧速率上限的视频游戏,另一种常见方法是在图形中强制启用垂直同步驱动程序设置。这通常会将渲染速度减慢至大约 60 FPS,这可能足以以合理的速率播放。但是,它仅适用于专门使用 3D 硬件渲染的应用程序。
最后:如果您不想使用虚拟机,也不想更改系统全局设置,而是只想为一个特定进程模拟旧 CPU,那么我有自己的程序来执行此操作,称为旧 CPU 模拟器。
操作的主脑是一个用C++编写的命令行工具,但也有一个用C#编写的GUI包装器。 GUI 需要 .NET Framework 4.0。在大多数情况下,默认设置应该没问题 - 只需在“目标速率”下选择您想要模拟的 CPU,然后点击“打开”并浏览您想要运行的程序。
https://github.com/tomysshadow/OldCPUSimulator(单击右侧的“发布”选项卡获取二进制文件。 )
这个概念是以精确的速率挂起和恢复进程,因为它发生得如此之快,所以进程看起来运行得很慢。例如,通过将进程挂起 3 毫秒,然后恢复 1 毫秒,它看起来会以 25% 的速度运行。通过控制暂停时间与恢复时间的比率,可以模拟不同的速度。这完全与 API 无关(它不挂钩 DirectX、OpenGL 等。如果需要,它可以与命令行程序一起工作。)
旧的 CPU 模拟器不要求百分比,而是要求模拟的时钟速度(它称为目标速率。)然后,它会根据 CPU 的实际时钟速度自动确定要使用的百分比。尽管时钟速度并不是随着时间的推移提高计算机性能的唯一因素(还有 SSD、更快的 GPU、更多 RAM、多线程性能等),但它是一个足够好的近似值,可以在给定相同目标速率的情况下在不同机器上获得相当一致的结果。它还支持其他可能有助于保持一致性的选项,例如将进程亲和力设置为 1。
它实现了三种不同的挂起和恢复进程的方法,并将使用最好的可用方法:NtSuspendProcess、NtQuerySystemInformation 或 Toolhelp Snapshots。它还使用timeBeginPeriod和timeEndPeriod来实现高精度计时,而无需忙循环。请注意,这不是模拟器;二进制文件仍然可以本地运行。如果您愿意,您可以查看源代码以了解它是如何实现的 - 这不是一个大项目。在我的机器上,Old CPU Simulator 使用不到 1% 的 CPU 和不到 1 MB 的内存,因此程序本身非常高效(不像运行密集型程序来故意降低 CPU 速度。)
There are a few different methods to accomplish this.
If you're using VirtualBox, go into the Settings for the VM you want to slow the CPU speed for. Go to System > Processor, then set the Execution Cap. The percentage controls how slow it will go: lower values are slower relative to the regular speed. In practice, I've noticed the results to be choppy, although it does technically work.
It is also possible to set the CPU speed for the whole system. In the Windows 10 Settings app, go to System > Power & Sleep. Then click Additional Power Settings on the right hand side. Go to Change Plan Settings for the currently selected plan, then click Change Advanced Power Plan Settings. Scroll down to Processor Power Management and set the Maximum Processor State. Again, this is a percentage. Although this does work, I find that in practice, it doesn't have a big impact even when the percentage is set very low.
If you're dealing with a videogame that uses DirectX or OpenGL and doesn't have a framerate cap, another common method is to force Vsync on in your graphics driver settings. This will usually slow the rendering to about 60 FPS which may be enough to play at a reasonable rate. However, it will only work for applications using 3D hardware rendering specifically.
Finally: if you'd rather not use a VM, and don't want to change a system global setting, but would rather simulate an old CPU for one specific process only, then I have my own program to do that called Old CPU Simulator.
The main brain of the operation is a command line tool written in C++, but there is also a GUI wrapper written in C#. The GUI requires .NET Framework 4.0. The default settings should be fine in most cases - just select the CPU you'd like to simulate under Target Rate, then hit Open and browse for the program you'd like to run.
https://github.com/tomysshadow/OldCPUSimulator (click the Releases tab on the right for binaries.)
The concept is to suspend and resume the process at a precise rate, and because it happens so quickly the process will appear to just be running slowly. For example, by suspending a process for 3 milliseconds, then resuming it for 1 millisecond, it will appear to be running at 25% speed. By controlling the ratio of time suspended vs. time resumed, it is possible to simulate different speeds. This is completely API agnostic (it doesn't hook DirectX, OpenGL, etc. it'll work with a command line program if you want.)
Old CPU Simulator does not ask for a percentage, but rather, the clock speed to simulate (which it calls the Target Rate.) It then automatically determines, based on your CPU's real clock speed, the percentage to use. Although clock speed is not the only factor that has improved computer performance over time (there are also SSDs, faster GPUs, more RAM, multithreaded performance, etc.) it's a good enough approximation to get fairly consistent results across machines given the same Target Rate. It also supports other options that may help with consistency, such as setting the process affinity to one.
It implements three different methods of suspending and resuming a process and will use the best available: NtSuspendProcess, NtQuerySystemInformation, or Toolhelp Snapshots. It also uses timeBeginPeriod and timeEndPeriod to achieve high precision timing without busy looping. Note that this is not an emulator; the binary still runs natively. If you like, you can view the source to see how it's implemented - it's not a large project. On my machine, Old CPU Simulator uses less than 1% CPU and less than 1 MB of memory, so the program itself is quite efficient (unlike running intensive programs to intentionally slow the CPU.)