Suntechnic

Bitrix test io

Jul 24th, 2021 (edited)
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. function getmicrotime()
  3. {
  4.     list($usec, $sec) = explode(" ", microtime());
  5.     return ((float)$usec + (float)$sec);
  6. }
  7.    
  8.    
  9. $res = array();
  10. $file_name = __DIR__."/. ./upload/perfmon#i#.php";
  11. $content = "<?\$s='".str_repeat("x", 1024)."';?><?/*".str_repeat("y", 1024)."*/?><?\$r='".str_repeat("z", 1024)."';?>";
  12.  
  13. for ($j = 0; $j < 4; $j++)
  14. {
  15.     $s1 = getmicrotime();
  16.     for ($i = 0; $i < 100; $i++)
  17.     {
  18.         $fn = str_replace("#i#", $i, $file_name);
  19.     }
  20.     $e1 = getmicrotime();
  21.     $N1 = $e1 - $s1;
  22.  
  23.     $s2 = getmicrotime();
  24.     for ($i = 0; $i < 100; $i++)
  25.     {
  26.         //This is one op
  27.         $fn = str_replace("#i#", $i, $file_name);
  28.         $fh = fopen($fn, "wb");
  29.         fwrite($fh, $content);
  30.         fclose($fh);
  31.         include($fn);
  32.         unlink($fn);
  33.     }
  34.     $e2 = getmicrotime();
  35.     $N2 = $e2 - $s2;
  36.  
  37.     if ($N2 > $N1)
  38.         $res[] = 100 / ($N2 - $N1);
  39. }
  40. if (count($res))
  41.     echo array_sum($res) / doubleval(count($res));
  42. else
  43.     echo 0;
RAW Paste Data