Advertisement
Guest User

Untitled

a guest
Jun 4th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.     $arr=Array();
  4.     $max=intval(file_get_contents('/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'))/100;
  5.     $ct=intval(shell_exec("ls /sys/devices/system/cpu/ | grep 'cpu[0-9]' | wc -l"));
  6.     for($i=0;$i<60;$i=$i+1){
  7.         for($x=0;$x<$ct;$x=$x+1){
  8.             $val=intval(file_get_contents("/sys/devices/system/cpu/cpu$x/cpufreq/cpuinfo_cur_freq"));
  9.             if(!in_array($val,$arr)){
  10.                 echo "Found: " . str_pad($val/1000,4," ",STR_PAD_LEFT) . " Mhz as " . str_pad(round($val/$max),3," ",STR_PAD_LEFT) . "%\n";
  11.                 array_push($arr,$val);
  12.             }
  13.         }
  14.         shell_exec('sleep 1');
  15.     }
  16.     sort($arr,SORT_NUMERIC);
  17.     $ct=count($arr);
  18.     echo implode(',',$arr). "\nTotal found: " . $ct . "\nSorted data:\n";
  19.     for($i=0;$i<$ct;$i=$i+1){
  20.         echo str_pad($arr[$i]/1000,4," ",STR_PAD_LEFT) . " Mhz as " . str_pad(round($arr[$i]/$max),3," ",STR_PAD_LEFT) . "%\n";
  21.     }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement