1

How can I create an artificially slow Javascript environment for in-browser testing on my fast Windows machine? Ultimately I'm trying to simulate lagginess and slow behavior that currently manifests in my Angular app only in iOS Safari.

(No IE8 jokes, ha ha!)

blaster
  • 8,876
  • 11
  • 48
  • 77
  • Run a VM with limited hardware? Use a proxy to stifle download speeds? – xyhhx Jul 08 '14 at 19:31
  • 1
    http://stackoverflow.com/questions/8521683/is-there-a-way-to-throttle-javascript-performance-to-simulate-a-slow-client and http://stackoverflow.com/questions/4673706/slow-down-cpu-to-simulate-slower-computers-in-browser-testing – j08691 Jul 08 '14 at 19:44
  • I created a free simple tool for Windows that allows anyone to enter the process ID and the desired CPU speed percentage, and it proceeds to simulate a slow CPU for that process. The utility itself barely consumes CPU time, which is a benefit. :) It's called "Slow CPU Emulator", check it out here: https://github.com/mathusummut/SlowCpuEmulator Precompiled binaries can be found here: https://sourceforge.net/projects/slowcpu – MathuSum Mut Nov 27 '18 at 20:55

2 Answers2

0

Probably not the 'best' way, but one thing to try would be to run a stress-test app, or create a process that runs at the highest priority, doing nothing much, sleeping at (and for) intervals that you tune to your liking.

SingleStepper
  • 348
  • 1
  • 10
0

On linux I use cpulimit. This command line helps to limit the macimum percentage of cpu used by a process. I found someone ported it to windows: https://github.com/alquerci/cpulimit/blob/master/README.md Still I can not confirm if it works. I haven't tested it myself on windows. All I can say is on linux it works like a charm.

Other technique you can try is to create an artificially big array and a timer (setInterval) that reads it for start to end every millisecond or so. That will break your cpu internal cache and really slow down your final JS.

earizon
  • 2,099
  • 19
  • 29