3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function onRequestStart() { $dat = getrusage(); define('PHP_TUSAGE', microtime(true)); define('PHP_RUSAGE', $dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"]); } function getCpuUsage() { $dat = getrusage(); $dat["ru_utime.tv_usec"] = ($dat["ru_utime.tv_sec"]*1e6 + $dat["ru_utime.tv_usec"]) - PHP_RUSAGE; $time = (microtime(true) - PHP_TUSAGE) * 1000000; // cpu per request if($time > 0) { $cpu = sprintf("%01.2f", ($dat["ru_utime.tv_usec"] / $time) * 100); } else { $cpu = '0.00'; } return $cpu; } onRequestStart(); for($i = 0; $i < 9999999; $i++){} echo getCpuUsage();
based on CalOI
Output for 7.1.0
98.66
Output for 7.0.14
100.17
Output for 7.0.6
97.32
Output for 7.0.5
97.89
Output for 7.0.4
100.74
Output for 5.2.0, 5.3.3, 7.0.3
100.08
Output for 7.0.2
98.00
Output for 7.0.1
102.17
Output for 5.6.17, 7.0.0
100.48
Output for 4.3.0 - 4.3.1, 4.3.4 - 4.4.1, 4.4.4 - 4.4.9, 5.6.28
0.00
Output for 5.6.21
99.07
Output for 5.5.26, 5.6.20
100.09
Output for 5.5.35, 5.6.19
100.01
Output for 5.6.18
99.85
Output for 5.6.16
99.82
Output for 5.3.21, 5.6.15
99.95
Output for 5.0.2, 5.5.28, 5.6.14
99.44
Output for 5.6.13
99.32
Output for 5.6.12
98.91
Output for 5.2.5, 5.6.11
99.77
Output for 5.6.10
84.20
Output for 5.6.9
99.50
Output for 5.6.8
99.26
Output for 5.5.34
99.25
Output for 5.2.12, 5.5.33
99.59
Output for 5.1.6, 5.5.32
99.69
Output for 5.5.31
99.62
Output for 5.3.16, 5.4.1, 5.5.30
100.00
Output for 5.5.29
100.50
Output for 5.5.27
100.11
Output for 5.5.25
100.39
Output for 5.5.24
99.43
Output for 5.4.45
60.13
Output for 5.4.44
47.66
Output for 5.4.43
94.78
Output for 5.4.42
74.74
Output for 5.4.41
85.60
Output for 5.4.40
46.49
Output for 5.4.39
62.28
Output for 5.4.38
79.78
Output for 5.4.37
85.23
Output for 5.4.36
85.37
Output for 5.4.35
89.22
Output for 5.4.34
88.27
Output for 5.4.22, 5.4.32
99.36
Output for 5.4.31
99.80
Output for 5.4.30
100.20
Output for 5.4.29
100.13
Output for 5.4.28
100.16
Output for 5.4.27
98.99
Output for 5.3.22, 5.4.26
99.96
Output for 5.4.25
99.84
Output for 5.3.5, 5.4.24
99.92
Output for 5.4.23
99.53
Output for 5.4.21
99.38
Output for 5.2.14, 5.3.7, 5.4.19 - 5.4.20
99.88
Output for 5.3.24, 5.4.0, 5.4.18
100.04
Output for 5.2.1, 5.4.17
100.07
Output for 5.4.16
99.40
Output for 5.4.15
99.73
Output for 5.1.4, 5.3.1, 5.4.14
99.55
Output for 5.4.13
98.54
Output for 5.2.6, 5.3.12, 5.4.12
100.18
Output for 5.4.11
99.81
Output for 5.4.10
99.03
Output for 5.4.9
97.99
Output for 5.4.8
100.32
Output for 5.1.5, 5.2.17, 5.4.7
99.94
Output for 5.3.26, 5.4.6
98.11
Output for 5.4.5
99.20
Output for 5.1.3, 5.3.14, 5.4.4
99.45
Output for 5.4.3
99.70
Output for 5.0.4, 5.2.8, 5.2.11, 5.4.2
99.83
Output for 5.3.29
99.28
Output for 5.3.28
100.03
Output for 5.3.27
100.26
Output for 5.3.17, 5.3.25
99.76
Output for 5.3.23
98.70
Output for 5.3.20
98.86
Output for 5.3.19
98.48
Output for 5.2.9, 5.3.18
99.54
Output for 5.0.1, 5.3.15
99.68
Output for 5.3.13
100.23
Output for 5.3.11
99.23
Output for 5.3.10
99.31
Output for 5.3.9
99.72
Output for 5.1.2, 5.3.8
99.75
Output for 5.3.6
96.89
Output for 5.3.4
100.10
Output for 5.2.7, 5.3.2
99.67
Output for 5.2.10, 5.3.0
99.99
Output for 5.2.16
98.28
Output for 5.2.13, 5.2.15
99.89
Output for 5.2.4
99.21
Output for 5.2.3
99.61
Output for 5.2.2
99.90
Output for 5.0.0, 5.1.1
99.86
Output for 5.1.0
99.93
Output for 5.0.5
99.41
Output for 5.0.3
99.56
Output for 4.4.3
99.91
Output for 4.3.3, 4.4.2
99.87
Output for 4.3.2
99.66