Operating System - Linux
1753774 Members
6993 Online
108799 Solutions
New Discussion юеВ

Re: How to find the cpu clock speed

 
SOLVED
Go to solution
Geoff Wild
Honored Contributor

Re: How to find the cpu clock speed

And of course the obligatory perl way:


# cat cpuspeed
perl -e 'local($PSTAT, $PSTAT_PROCESSOR)=(239,10);
local($struct_pst_processor)=("L30");
local($cpu_info, $cpu_ticks);
$cpu_info = "\0" x 120;
syscall($PSTAT, $PSTAT_PROCESSOR, $cpu_info, length($cpu_info), 1, 0);
($cpu_ticks)=(unpack($struct_pst_processor, $cpu_info))[26];
print "speed=".int($cpu_ticks/10000)." Mhz\n";'


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Geoff Wild
Honored Contributor

Re: How to find the cpu clock speed

And this Perl one will tell if it is parisc:

# cat cpuinfo
perl -MUnix::Processors -le'print join"\t",$_->id,$_->state,$_->type,$_->clock for @{Unix::Processors->new()->processors}'


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Raj D.
Honored Contributor

Re: How to find the cpu clock speed

Santosh ,

Also dont forget the easy one :

SAM--> Performance Monitors --> System Properties.


Processors:
Active: 2
Total: 2
CPU Version: 2.0 PA8500
Clock Frequency: 360 MHz
Machine Identification: 145901547
Hardware Model: 9000/800/L2000-36
Kernel Width Support: 64
-----------------------------------------


cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Biswajit Tripathy
Honored Contributor

Re: How to find the cpu clock speed

To complete the set the choices you have,
here is the C program :-)

#include
#include
#include
int main()
{
struct pst_processor psp;
unsigned long int clock_speed, scclktick;
pstat_getprocessor(&psp, sizeof(psp), 1, 0);
scclktick=sysconf(_SC_CLK_TCK);
clock_speed = psp.psp_iticksperclktick * scclktick;
printf("CPU clock speed is %ld Mhz\n", clock_speed/1000000);
}

Compile and run to get the cpu speed.

- Biswajit
:-)