Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2. // Script start
  3. $rustart = getrusage();
  4.  
  5. $a=array();
  6. //$j = new Judy(Judy::STRING_TO_MIXED);
  7. //$j = new Judy(Judy::INT_TO_INT);
  8.  
  9. $j = new Judy(Judy::STRING_TO_INT);
  10. for ($i=0; $i<=15000; $i++){
  11.  
  12.     //12 секунд
  13. //    $a['k'.$i]=$i;
  14. //    $e = count($a);
  15. //    $secondField = array_keys($a)[0];
  16.  
  17.     //400 мс.
  18.     $j['k'.$i]=$i;
  19.     $e = $j->count();
  20.     $secondField = $j->first();
  21. }
  22.  
  23.  
  24.  
  25.  
  26. // Script end
  27. function rutime($ru, $rus, $index) {
  28.     return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
  29.     -  ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000));
  30. }
  31.  
  32. $ru = getrusage();
  33. echo "This process used " . rutime($ru, $rustart, "utime") .
  34.     " ms for its computations\n";
  35. echo "It spent " . rutime($ru, $rustart, "stime") .
  36.     " ms in system calls\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement