Application to (deliberately) consume CPU time?

5

1

Is there an application designed to consume a user defined amount of CPU time? For testing purposes?

For instance, it could be set to consume 57% of available CPU time to slow down some other application sufficiently, but not too much, in order to acquire a screenshot of a transient phenomenon.

For Unix systems there is stress, "workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system.".

Platform: Windows.

Peter Mortensen

Posted 2010-07-24T13:36:23.967

Reputation: 10 992

If you wanted to take a slo-mo screenshot, you could just pull a frame out of a screencast using CamStudio or the like. – digitxp – 2010-08-27T20:38:09.790

Answers

1

There's a piece of software called Battle Encoder Shirase which is designed to do exactly this.

It functions not by consuming excess CPU time, but by rapidly suspending and resuming the target progress. It works much like a cheap dimmer switch. The result is much more consistent and predictable than something like stress, but in any case the results are pretty much the same.

Imagine 'voltage' means resumed at high, and suspended at low. If you set it to throttle the CPU of a particular process down to 25%, the process would run like so:

pulse width modulation

zildjohn01

Posted 2010-07-24T13:36:23.967

Reputation: 2 212

Yes, this (almost) work. Running "stress" in Cygwin with 1 process on a quad core system and limit set in Battle Encoder Shirase to 80% (20% left for the "stress" process) resulted in close to the expected CPU load of 25% x 0.2 = 3.75%. But "stress" is not suitable for this purpose as it starts a separate process for each CPU: There are only 3 targets in Battle Encoder Shirase and it can not limit for the 4th CPU on a quad core system. Battle Encoder Shirase remains the key to the solution, a program that uses 4 threads instead of 4 processes to load the CPUs is needed. – Peter Mortensen – 2010-09-04T16:24:27.933

1

I bet there are dozens of stress replacements if you look around. For example here's one: http://weblogs.asp.net/kennykerr/archive/2005/10/22/Max-CPU_3A00_-Another-one-for-your-developer-toolbox_2E002E002E00_.aspx

– zildjohn01 – 2010-09-04T16:48:07.177

3

The question seems difficult. I don't know of any tools which track CPU utilization and control their load according to it. I know that this was a problem for SETI@home project. They solved it by taking a time unit (can't remember if it was a second or a minute...) and have CPU loaded at 100% for one portion of it. So when user sets CPU load a 50%, half of the time unit CPU would run at 100% and other half at 0%. You can try with S@H and see if it will work for you. Link: http://setiathome.berkeley.edu

There is also Mo'Slo, but I haven't used it since DOS days and I don't know how good it works under windows. It seems it works by making the target program use less CPU time, so it isn't what you need.

AndrejaKo

Posted 2010-07-24T13:36:23.967

Reputation: 16 459

2

CPU Burn tools usually focus on taking up all cycles.
Your requirement is interesting and I wonder if this can be done with a controlled version of the tool that will look its own CPU utilization and tune itself up or down to match a configured setting.

The classic form of the CPU burning tool is the Mersenne Prime Search.
This is the place to get its source versions.


Rambling on ideas.
As an example of self tuning I recall writing a curve-plotting tool some time back that used an approximate curve plot with increasing accuracy (more iterations/recursion to get better curves). I converted it into a 'benchmark' of sorts by measuring the time taken to compute each iteration of the curve. I wanted to keep moving the curve (think screen savers) on the screen after drawing it with a sufficient accuracy. Based on the speed of the system under test, I tuned the movement (animation) to work at something like a 25 frame rate. So, faster systems showed better curves!

What you would do with the prime search code is to add in a CPU utilization 'sensor' and use it to slow down or increase the computation rate (to approximate configured CPU utilization).

This part of the answer would probably better suit on Stackoverflow :-)
Seeing you are active there too, maybe this would interest you.

nik

Posted 2010-07-24T13:36:23.967

Reputation: 50 788