[ltp] Running without a battery?

mukesh agrawal linux-thinkpad@linux-thinkpad.org
Wed, 14 Jan 2004 09:45:40 -0500 (EST)


On Wed, 14 Jan 2004, Dr. Jason Breitweg wrote:

> Yeah, that would be really cool if you could check that out.  How does
> one tell if the CPU is running at a lower speed?

Any program that just executes a CPU loop would work. bogomips is one such
program, that might already be installed.

If not, something like the following should do the trick:

--- spin.c ---

main() {
	int i = 1E6;

	while (i) --i;
}

--------------

% gcc spin.c -o spin
% time spin

Just compare how long it takes to execute (plugged in vs unplugged, or
whatever scenarios you want).

You might need to adjust the value of i up or down, depending on how long
it takes to execute. (If it returns in less than 1 second in both cases,
make i bigger.)