Guest User

Untitled

a guest
Jun 24th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. function GetPHPFilesMark()
  3. {
  4. $res = array();
  5. $file_name = $_SERVER["DOCUMENT_ROOT"]."/upload/perfmon#i#.php";
  6. $content = "<?\$s='".str_repeat("x", 1024)."';?><?/*".str_repeat("y", 1024)."*/?><?\$r='".str_repeat("z", 1024)."';?>";
  7.  
  8. for ($j = 0; $j < 4; $j++)
  9. {
  10. $s1 = microtime(true);
  11. for ($i = 0; $i < 100; $i++)
  12. {
  13. $fn = str_replace("#i#", $i, $file_name);
  14. }
  15. $e1 = microtime(true);
  16. $N1 = $e1 - $s1;
  17.  
  18. $s2 = microtime(true);
  19. for ($i = 0; $i < 100; $i++)
  20. {
  21. //This is one op
  22. $fn = str_replace("#i#", $i, $file_name);
  23. $fh = fopen($fn, "wb");
  24. fwrite($fh, $content);
  25. fclose($fh);
  26. include($fn);
  27. unlink($fn);
  28. }
  29. $e2 = microtime(true);
  30. $N2 = $e2 - $s2;
  31.  
  32. if ($N2 > $N1)
  33. $res[] = 100 / ($N2 - $N1);
  34. }
  35.  
  36. if (count($res))
  37. return array_sum($res) / doubleval(count($res));
  38. else
  39. return 0;
  40. }
  41. echo "<pre>";
  42. print_r(GetPHPFilesMark());
  43. echo "</pre>";
Add Comment
Please, Sign In to add comment