Added lot of junk laying around on harvie.cz
[mirrors/Programs.git] / php / skripty / cpuload.php
diff --git a/php/skripty/cpuload.php b/php/skripty/cpuload.php
new file mode 100644 (file)
index 0000000..ab311a2
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+//CPULoad\r
+\r
+function getmicrotime(){\r
+   list($usec, $sec) = explode(" ",microtime());\r
+   return ((float)$usec);\r
+   } \r
+   \r
+   \r
+$c = 0;\r
+$ind = 0;\r
+while($c < 0.3) {    // max 0.3\r
+  $a = getmicrotime();\r
+\r
+////////////////////////////////////////////////////////////////\r
+    /*\r
+    for ($i=0; $i < 1000; $i++){\r
+      $x = cos(sin(cos(sin(cos(sin(60))))));\r
+    }\r
+    */\r
+    \r
+    $desc = array(\r
+   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from\r
+   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to\r
+   2 => array("pipe", "r") // stderr is a file to write to\r
+);\r
+\r
+$proc[$ind] = proc_open("proctest.exe", $desc, $pipes);\r
+$ind = ($ind + 1);\r
+\r
+////////////////////////////////////////////////////////////////\r
+\r
+  $b = getmicrotime();\r
+  $c = round(($b - $a), 10);\r
+  echo($c."\n");\r
+  \r
+  }\r
+\r
+echo("end");\r
+system("taskkill /f /im proctest.exe");\r
+echo("OK");\r
+?>\r
This page took 0.148198 seconds and 4 git commands to generate.