| 1 | <?php\r |
| 2 | //CPULoad\r |
| 3 | \r |
| 4 | function getmicrotime(){\r |
| 5 | list($usec, $sec) = explode(" ",microtime());\r |
| 6 | return ((float)$usec);\r |
| 7 | } \r |
| 8 | \r |
| 9 | \r |
| 10 | $c = 0;\r |
| 11 | $ind = 0;\r |
| 12 | while($c < 0.3) { // max 0.3\r |
| 13 | $a = getmicrotime();\r |
| 14 | \r |
| 15 | ////////////////////////////////////////////////////////////////\r |
| 16 | /*\r |
| 17 | for ($i=0; $i < 1000; $i++){\r |
| 18 | $x = cos(sin(cos(sin(cos(sin(60))))));\r |
| 19 | }\r |
| 20 | */\r |
| 21 | \r |
| 22 | $desc = array(\r |
| 23 | 0 => array("pipe", "r"), // stdin is a pipe that the child will read from\r |
| 24 | 1 => array("pipe", "w"), // stdout is a pipe that the child will write to\r |
| 25 | 2 => array("pipe", "r") // stderr is a file to write to\r |
| 26 | );\r |
| 27 | \r |
| 28 | $proc[$ind] = proc_open("proctest.exe", $desc, $pipes);\r |
| 29 | $ind = ($ind + 1);\r |
| 30 | \r |
| 31 | ////////////////////////////////////////////////////////////////\r |
| 32 | \r |
| 33 | $b = getmicrotime();\r |
| 34 | $c = round(($b - $a), 10);\r |
| 35 | echo($c."\n");\r |
| 36 | \r |
| 37 | }\r |
| 38 | \r |
| 39 | echo("end");\r |
| 40 | system("taskkill /f /im proctest.exe");\r |
| 41 | echo("OK");\r |
| 42 | ?>\r |