MHZ(8) - LMBENCH man page


NAME

mhz - calulate processor clock rate

SYNOPSIS

mhz [-c]

DESCRIPTION

mhz calculates the processor clock rate and megahertz. It uses an unrolled, interlocked loop of adds or shifts. So far, superscalarness has been defeated on the tested processors (SuperSPARC, RIOS, Alpha).

OUTPUT

Output format is either just the clock rate as a float (-c) or more verbose


39.80 Mhz, 25 nanosec clock

BUGS

This program is highly compiler sensitive. GCC seems to almost always do the right thing. The right thing is this: the main loop is a series of dependent integer operations, such as a++; a++; a++; ... The variable is declared as a register integer and it is hoped that the compiler, without optimization since optimizing would remove the whole loop, will turn that directly into one instruction.

This is not always the case. If you think that your mhz output is wrong, check the compiler output by compiling like so cc -S mhz.c and then examining mhz.s. It should have a bunch of identical instructions at the bottom of the file. All of the instructions should be adds or shifts of the same registers, over and over. If it is loading, adding, storing, then it failed to put the variable in a register. It probably put the variable on the stack. Try gcc if this happens.

ACKNOWLEDGEMENT

Funding for the development of this tool was provided by Sun Microsystems Computer Corporation.

SEE ALSO

lmbench(8).