<?php
class A {
public static function test() {
return true;
}
}
function test() {
static $a;
return $a ??= new A;
}
$its = 1e3;
$test = test();
$t = hrtime(true);
for ( $i=0;$i++<$its;)
test()->test();
echo (hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$test->test();
echo (hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
A::test();
echo (hrtime(true)-$t)/1e9,"s\n";
echo "\n=== Warmed up ===\n\n";
$its = 1e6;
$t = hrtime(true);
for ( $i=0;$i++<$its;)
test()->test();
echo $a=(hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
$test->test();
echo $b=(hrtime(true)-$t)/1e9,"s\n";
$t = hrtime(true);
for ( $i=0;$i++<$its;)
A::test();
echo $c=(hrtime(true)-$t)/1e9,"s\n";
echo number_format((($a-$c)/$a) * 100, 2 ), "% faster from function\n";
echo number_format((($b-$c)/$b) * 100, 2 ), "% faster from variable\n";
- Output for 8.3.14
- 2.879E-5s
9.101E-6s
9.1E-6s
=== Warmed up ===
0.028696041s
0.009008713s
0.009987532s
65.20% faster from function
-10.87% faster from variable
- Output for 8.3.13
- 7.1607E-5s
2.2584E-5s
2.2303E-5s
=== Warmed up ===
0.050738816s
0.00914842s
0.009039677s
82.18% faster from function
1.19% faster from variable
- Output for 8.3.12
- 3.0115E-5s
9.264E-6s
1.0225E-5s
=== Warmed up ===
0.03093044s
0.009063703s
0.008820155s
71.48% faster from function
2.69% faster from variable
- Output for 8.3.11
- 2.8602E-5s
1.4914E-5s
1.4021E-5s
=== Warmed up ===
0.027568267s
0.008993213s
0.008993914s
67.38% faster from function
-0.01% faster from variable
- Output for 8.3.10
- 2.8974E-5s
9.114E-6s
9.254E-6s
=== Warmed up ===
0.027629548s
0.008874582s
0.008831469s
68.04% faster from function
0.49% faster from variable
- Output for 8.3.9
- 2.8213E-5s
1.6314E-5s
1.5333E-5s
=== Warmed up ===
0.02795446s
0.0090259s
0.008604085s
69.22% faster from function
4.67% faster from variable
- Output for 8.3.8
- 3.5706E-5s
1.098E-5s
1.0821E-5s
=== Warmed up ===
0.035783298s
0.010587388s
0.010599873s
70.38% faster from function
-0.12% faster from variable
- Output for 8.3.7
- 8.571E-5s
4.4137E-5s
4.2335E-5s
=== Warmed up ===
0.064373114s
0.016488089s
0.015886912s
75.32% faster from function
3.65% faster from variable
- Output for 8.3.6
- 9.8468E-5s
4.4627E-5s
3.7688E-5s
=== Warmed up ===
0.061699085s
0.016869634s
0.016811235s
72.75% faster from function
0.35% faster from variable
- Output for 8.3.5
- 6.624E-5s
2.1012E-5s
2.1853E-5s
=== Warmed up ===
0.065619956s
0.016933636s
0.018150529s
72.34% faster from function
-7.19% faster from variable
- Output for 8.3.4
- 6.8393E-5s
2.5909E-5s
2.8153E-5s
=== Warmed up ===
0.055982308s
0.018323746s
0.017940119s
67.95% faster from function
2.09% faster from variable
- Output for 8.3.3
- 5.4042E-5s
3.0075E-5s
2.8793E-5s
=== Warmed up ===
0.051804378s
0.016776212s
0.016784355s
67.60% faster from function
-0.05% faster from variable
- Output for 8.3.2
- 7.0285E-5s
3.4712E-5s
3.964E-5s
=== Warmed up ===
0.052818374s
0.008981629s
0.008822419s
83.30% faster from function
1.77% faster from variable
- Output for 8.3.1
- 8.7532E-5s
3.9349E-5s
3.6155E-5s
=== Warmed up ===
0.054246212s
0.008908692s
0.01012175s
81.34% faster from function
-13.62% faster from variable
- Output for 8.3.0
- 2.7882E-5s
9.274E-6s
9.104E-6s
=== Warmed up ===
0.028324909s
0.008876105s
0.00878617s
68.98% faster from function
1.01% faster from variable
- Output for 8.2.25
- 3.0255E-5s
9.454E-6s
9.274E-6s
=== Warmed up ===
0.028928302s
0.00906608s
0.008611939s
70.23% faster from function
5.01% faster from variable
- Output for 8.2.24
- 0.000124799s
3.6345E-5s
3.996E-5s
=== Warmed up ===
0.07017448s
0.020056109s
0.012012436s
82.88% faster from function
40.11% faster from variable
- Output for 8.2.23
- 2.9424E-5s
9.495E-6s
8.913E-6s
=== Warmed up ===
0.028499078s
0.009094041s
0.008519584s
70.11% faster from function
6.32% faster from variable
- Output for 8.2.22
- 2.9424E-5s
9.264E-6s
9.204E-6s
=== Warmed up ===
0.032214354s
0.008865311s
0.010061504s
68.77% faster from function
-13.49% faster from variable
- Output for 8.2.21
- 2.9715E-5s
1.5433E-5s
1.5003E-5s
=== Warmed up ===
0.029220447s
0.009516068s
0.009508697s
67.46% faster from function
0.08% faster from variable
- Output for 8.2.20
- 3.5787E-5s
1.108E-5s
1.1683E-5s
=== Warmed up ===
0.036312087s
0.010687967s
0.010658201s
70.65% faster from function
0.28% faster from variable
- Output for 8.2.19
- 8.1052E-5s
2.5639E-5s
4.2514E-5s
=== Warmed up ===
0.072595133s
0.016824762s
0.020400222s
71.90% faster from function
-21.25% faster from variable
- Output for 8.2.18
- 5.4672E-5s
2.5699E-5s
2.4857E-5s
=== Warmed up ===
0.053987903s
0.016930906s
0.01600547s
70.35% faster from function
5.47% faster from variable
- Output for 8.2.17
- 8.3816E-5s
3.295E-5s
3.3871E-5s
=== Warmed up ===
0.082514047s
0.03307493s
0.033631208s
59.24% faster from function
-1.68% faster from variable
- Output for 8.2.16
- 7.9961E-5s
2.5848E-5s
2.7992E-5s
=== Warmed up ===
0.061967822s
0.016520579s
0.017747885s
71.36% faster from function
-7.43% faster from variable
- Output for 8.2.15
- 2.8292E-5s
1.4953E-5s
1.4161E-5s
=== Warmed up ===
0.027251504s
0.009156798s
0.009280805s
65.94% faster from function
-1.35% faster from variable
- Output for 8.2.14
- 2.8564E-5s
1.5493E-5s
1.6134E-5s
=== Warmed up ===
0.027405807s
0.009038243s
0.010191571s
62.81% faster from function
-12.76% faster from variable
- Output for 8.2.13
- 7.2519E-5s
2.3355E-5s
2.5208E-5s
=== Warmed up ===
0.050289964s
0.009074123s
0.009507435s
81.09% faster from function
-4.78% faster from variable
- Output for 8.2.12
- 7.3491E-5s
2.3405E-5s
2.2623E-5s
=== Warmed up ===
0.044944075s
0.008986822s
0.008609063s
80.84% faster from function
4.20% faster from variable
- Output for 8.2.11
- 5.5934E-5s
1.4652E-5s
1.4853E-5s
=== Warmed up ===
0.055026072s
0.01450763s
0.014928143s
72.87% faster from function
-2.90% faster from variable
- Output for 8.2.10
- 3.7311E-5s
1.4627E-5s
1.3685E-5s
=== Warmed up ===
0.032203841s
0.013950604s
0.013268789s
58.80% faster from function
4.89% faster from variable
- Output for 8.2.9
- 3.758E-5s
1.4738E-5s
1.4076E-5s
=== Warmed up ===
0.034836515s
0.013910597s
0.01316298s
62.21% faster from function
5.37% faster from variable
- Output for 8.2.8
- 3.4936E-5s
1.4378E-5s
1.3536E-5s
=== Warmed up ===
0.031938852s
0.014467305s
0.013134777s
58.88% faster from function
9.21% faster from variable
- Output for 8.2.7
- 3.6558E-5s
1.7553E-5s
1.7923E-5s
=== Warmed up ===
0.03322383s
0.014034189s
0.013553115s
59.21% faster from function
3.43% faster from variable
- Output for 8.2.6
- 3.6157E-5s
1.9496E-5s
2.0609E-5s
=== Warmed up ===
0.031984749s
0.014289349s
0.013441585s
57.98% faster from function
5.93% faster from variable
- Output for 8.2.5
- 3.7481E-5s
1.4247E-5s
1.3825E-5s
=== Warmed up ===
0.036171657s
0.013945763s
0.01304125s
63.95% faster from function
6.49% faster from variable
- Output for 8.2.4
- 3.5036E-5s
1.4497E-5s
1.3815E-5s
=== Warmed up ===
0.03369142s
0.01382168s
0.013128285s
61.03% faster from function
5.02% faster from variable
- Output for 8.2.3
- 3.5636E-5s
1.4338E-5s
1.4116E-5s
=== Warmed up ===
0.032850588s
0.013923542s
0.013244995s
59.68% faster from function
4.87% faster from variable
- Output for 8.2.2
- 3.2992E-5s
1.4577E-5s
2.8864E-5s
=== Warmed up ===
0.032358822s
0.013925255s
0.013312771s
58.86% faster from function
4.40% faster from variable
- Output for 8.2.1
- 3.6429E-5s
1.4608E-5s
1.3886E-5s
=== Warmed up ===
0.034438537s
0.013877454s
0.013249152s
61.53% faster from function
4.53% faster from variable
- Output for 8.2.0
- 3.6629E-5s
1.7282E-5s
1.7403E-5s
=== Warmed up ===
0.032752574s
0.013839282s
0.013212893s
59.66% faster from function
4.53% faster from variable
- Output for 8.1.30
- 3.0016E-5s
9.444E-6s
1.0276E-5s
=== Warmed up ===
0.028828946s
0.009272457s
0.0095405s
66.91% faster from function
-2.89% faster from variable
- Output for 8.1.29
- 3.6699E-5s
1.1432E-5s
1.0911E-5s
=== Warmed up ===
0.037267677s
0.011103526s
0.010906346s
70.74% faster from function
1.78% faster from variable
- Output for 8.1.28
- 5.4101E-5s
1.6996E-5s
1.978E-5s
=== Warmed up ===
0.053299744s
0.016751609s
0.019485809s
63.44% faster from function
-16.32% faster from variable
- Output for 8.1.27
- 2.9344E-5s
9.614E-6s
9.144E-6s
=== Warmed up ===
0.028374887s
0.00920925s
0.008970561s
68.39% faster from function
2.59% faster from variable
- Output for 8.1.26
- 2.9164E-5s
1.5483E-5s
1.5203E-5s
=== Warmed up ===
0.028268441s
0.008991835s
0.009178456s
67.53% faster from function
-2.08% faster from variable
- Output for 8.1.25
- 0.000106992s
1.4582E-5s
1.4912E-5s
=== Warmed up ===
0.027934954s
0.009026953s
0.008688973s
68.90% faster from function
3.74% faster from variable
- Output for 8.1.24
- 5.7818E-5s
1.7256E-5s
1.6945E-5s
=== Warmed up ===
0.056919876s
0.014509528s
0.014174484s
75.10% faster from function
2.31% faster from variable
- Output for 8.1.23
- 3.2941E-5s
1.4287E-5s
1.3516E-5s
=== Warmed up ===
0.031902225s
0.013954058s
0.012887091s
59.60% faster from function
7.65% faster from variable
- Output for 8.1.22
- 3.5577E-5s
1.4688E-5s
1.3565E-5s
=== Warmed up ===
0.033163948s
0.013871623s
0.012853708s
61.24% faster from function
7.34% faster from variable
- Output for 8.1.21
- 3.7189E-5s
1.4649E-5s
1.3666E-5s
=== Warmed up ===
0.034437856s
0.013913753s
0.013121762s
61.90% faster from function
5.69% faster from variable
- Output for 8.1.20
- 3.3494E-5s
1.7302E-5s
1.3716E-5s
=== Warmed up ===
0.032111667s
0.014008712s
0.013039216s
59.39% faster from function
6.92% faster from variable
- Output for 8.1.19
- 3.3152E-5s
1.4548E-5s
1.6892E-5s
=== Warmed up ===
0.032015325s
0.013981511s
0.012922317s
59.64% faster from function
7.58% faster from variable
- Output for 8.1.18
- 3.3522E-5s
1.7113E-5s
1.7412E-5s
=== Warmed up ===
0.032196357s
0.013835716s
0.012883865s
59.98% faster from function
6.88% faster from variable
- Output for 8.1.17
- 3.3503E-5s
1.4758E-5s
1.4467E-5s
=== Warmed up ===
0.032254928s
0.014165215s
0.012867775s
60.11% faster from function
9.16% faster from variable
- Output for 8.1.16
- 3.4916E-5s
1.4688E-5s
1.4206E-5s
=== Warmed up ===
0.031899358s
0.013847949s
0.012805257s
59.86% faster from function
7.53% faster from variable
- Output for 8.1.15
- 3.3173E-5s
1.4407E-5s
1.3376E-5s
=== Warmed up ===
0.032011059s
0.013799728s
0.013576698s
57.59% faster from function
1.62% faster from variable
- Output for 8.1.14
- 3.4605E-5s
1.4828E-5s
1.3876E-5s
=== Warmed up ===
0.033111639s
0.013802713s
0.012966269s
60.84% faster from function
6.06% faster from variable
- Output for 8.1.13
- 3.4264E-5s
1.4618E-5s
1.3445E-5s
=== Warmed up ===
0.032507463s
0.014172369s
0.012962052s
60.13% faster from function
8.54% faster from variable
- Output for 8.1.12
- 3.3463E-5s
2.159E-5s
2.0949E-5s
=== Warmed up ===
0.032510367s
0.013965018s
0.013013429s
59.97% faster from function
6.81% faster from variable
- Output for 8.1.11
- 3.683E-5s
1.7132E-5s
1.8404E-5s
=== Warmed up ===
0.032515208s
0.013928691s
0.012934099s
60.22% faster from function
7.14% faster from variable
- Output for 8.1.10
- 3.649E-5s
1.4447E-5s
1.4217E-5s
=== Warmed up ===
0.034063771s
0.014019111s
0.013053635s
61.68% faster from function
6.89% faster from variable
- Output for 8.1.9
- 3.2412E-5s
1.4407E-5s
3.4655E-5s
=== Warmed up ===
0.031790273s
0.013868678s
0.012890237s
59.45% faster from function
7.06% faster from variable
- Output for 8.1.8
- 3.3162E-5s
1.6931E-5s
1.587E-5s
=== Warmed up ===
0.032071281s
0.01448074s
0.012874386s
59.86% faster from function
11.09% faster from variable
- Output for 8.1.7
- 3.2872E-5s
1.7513E-5s
1.7522E-5s
=== Warmed up ===
0.034337665s
0.013887302s
0.012948095s
62.29% faster from function
6.76% faster from variable
- Output for 8.1.6
- 3.3393E-5s
1.5449E-5s
1.3766E-5s
=== Warmed up ===
0.032220772s
0.014032356s
0.012915253s
59.92% faster from function
7.96% faster from variable
- Output for 8.1.5
- 3.3853E-5s
1.5238E-5s
1.3726E-5s
=== Warmed up ===
0.032017179s
0.013921297s
0.01282828s
59.93% faster from function
7.85% faster from variable
- Output for 8.1.4
- 3.5316E-5s
1.4537E-5s
1.4117E-5s
=== Warmed up ===
0.033707521s
0.013841847s
0.012938577s
61.62% faster from function
6.53% faster from variable
- Output for 8.1.3
- 3.8703E-5s
1.8717E-5s
1.9397E-5s
=== Warmed up ===
0.037587342s
0.013966562s
0.013064645s
65.24% faster from function
6.46% faster from variable
- Output for 8.1.2
- 3.3242E-5s
1.4387E-5s
1.4016E-5s
=== Warmed up ===
0.03376579s
0.013883545s
0.013415145s
60.27% faster from function
3.37% faster from variable
- Output for 8.1.1
- 3.4705E-5s
1.4848E-5s
1.7362E-5s
=== Warmed up ===
0.032150651s
0.014046403s
0.013515643s
57.96% faster from function
3.78% faster from variable
- Output for 8.1.0
- 3.3973E-5s
1.6701E-5s
1.6902E-5s
=== Warmed up ===
0.032273413s
0.01394414s
0.015250759s
52.75% faster from function
-9.37% faster from variable
- Output for 8.0.30
- 5.343E-5s
1.9366E-5s
1.8985E-5s
=== Warmed up ===
0.041680483s
0.013896961s
0.013671647s
67.20% faster from function
1.62% faster from variable
- Output for 8.0.29
- 4.4695E-5s
1.9597E-5s
2.0198E-5s
=== Warmed up ===
0.034371951s
0.013942376s
0.013840835s
59.73% faster from function
0.73% faster from variable
- Output for 8.0.28
- 4.3953E-5s
2.0608E-5s
1.7785E-5s
=== Warmed up ===
0.03504616s
0.013961542s
0.013690252s
60.94% faster from function
1.94% faster from variable
- Output for 8.0.27
- 3.5907E-5s
1.4567E-5s
1.4288E-5s
=== Warmed up ===
0.03308019s
0.014039028s
0.013731851s
58.49% faster from function
2.19% faster from variable
- Output for 8.0.26
- 4.9513E-5s
1.7933E-5s
1.9576E-5s
=== Warmed up ===
0.041279991s
0.013997149s
0.013574264s
67.12% faster from function
3.02% faster from variable
- Output for 8.0.25
- 4.5265E-5s
1.7954E-5s
1.9616E-5s
=== Warmed up ===
0.033425118s
0.014031093s
0.013376953s
59.98% faster from function
4.66% faster from variable
- Output for 8.0.24
- 0.001281551s
2.1099E-5s
1.9196E-5s
=== Warmed up ===
0.034662277s
0.013876703s
0.013489394s
61.08% faster from function
2.79% faster from variable
- Output for 8.0.23
- 3.5026E-5s
1.4737E-5s
2.9866E-5s
=== Warmed up ===
0.034791871s
0.014136602s
0.013303084s
61.76% faster from function
5.90% faster from variable
- Output for 8.0.22
- 4.6116E-5s
1.8785E-5s
1.8925E-5s
=== Warmed up ===
0.035214197s
0.013936335s
0.014882888s
57.74% faster from function
-6.79% faster from variable
- Output for 8.0.21
- 4.7349E-5s
1.8064E-5s
1.9237E-5s
=== Warmed up ===
0.035389735s
0.014052324s
0.013448648s
62.00% faster from function
4.30% faster from variable
- Output for 8.0.20
- 4.1359E-5s
1.4617E-5s
2.8745E-5s
=== Warmed up ===
0.035621812s
0.013998282s
0.013791802s
61.28% faster from function
1.48% faster from variable
- Output for 8.0.19
- 4.9855E-5s
1.9918E-5s
1.8875E-5s
=== Warmed up ===
0.035107074s
0.013928721s
0.013513099s
61.51% faster from function
2.98% faster from variable
- Output for 8.0.18
- 3.7501E-5s
1.4718E-5s
2.8383E-5s
=== Warmed up ===
0.03323442s
0.013948589s
0.013577971s
59.14% faster from function
2.66% faster from variable
- Output for 8.0.17
- 3.7291E-5s
1.6681E-5s
1.7002E-5s
=== Warmed up ===
0.033525779s
0.013946434s
0.013622815s
59.37% faster from function
2.32% faster from variable
- Output for 8.0.16
- 4.7429E-5s
1.9577E-5s
1.9156E-5s
=== Warmed up ===
0.032488376s
0.013884958s
0.014289771s
56.02% faster from function
-2.92% faster from variable
- Output for 8.0.15
- 4.5646E-5s
1.8785E-5s
3.1188E-5s
=== Warmed up ===
0.033235302s
0.013816089s
0.013446093s
59.54% faster from function
2.68% faster from variable
- Output for 8.0.14
- 3.4154E-5s
1.8725E-5s
1.8976E-5s
=== Warmed up ===
0.032851699s
0.01410855s
0.015908827s
51.57% faster from function
-12.76% faster from variable
- Output for 8.0.13
- 4.7018E-5s
1.8896E-5s
1.8045E-5s
=== Warmed up ===
0.033175749s
0.013796411s
0.01365208s
58.85% faster from function
1.05% faster from variable
- Output for 8.0.12
- 4.7028E-5s
2.0259E-5s
1.8194E-5s
=== Warmed up ===
0.032779284s
0.013902651s
0.013521575s
58.75% faster from function
2.74% faster from variable
- Output for 8.0.11
- 3.3302E-5s
1.7563E-5s
1.6701E-5s
=== Warmed up ===
0.033066364s
0.013865262s
0.013644035s
58.74% faster from function
1.60% faster from variable
- Output for 8.0.10
- 3.4224E-5s
1.4448E-5s
2.9135E-5s
=== Warmed up ===
0.033061535s
0.013937688s
0.013701764s
58.56% faster from function
1.69% faster from variable
- Output for 8.0.9
- 3.3784E-5s
1.4168E-5s
1.4026E-5s
=== Warmed up ===
0.033015548s
0.013892032s
0.013454479s
59.25% faster from function
3.15% faster from variable
- Output for 8.0.8
- 4.2359E-5s
1.6522E-5s
1.8324E-5s
=== Warmed up ===
0.032557065s
0.013795571s
0.013372104s
58.93% faster from function
3.07% faster from variable
- Output for 8.0.7
- 3.5337E-5s
1.4307E-5s
2.9627E-5s
=== Warmed up ===
0.03309077s
0.013791573s
0.013547984s
59.06% faster from function
1.77% faster from variable
- Output for 8.0.6
- 0.001226247s
1.8725E-5s
1.8445E-5s
=== Warmed up ===
0.033222329s
0.013937196s
0.013541853s
59.24% faster from function
2.84% faster from variable
- Output for 8.0.5
- 0.001326126s
1.8605E-5s
1.8274E-5s
=== Warmed up ===
0.034550458s
0.013933559s
0.013625902s
60.56% faster from function
2.21% faster from variable
- Output for 8.0.3
- 0.001278646s
1.4487E-5s
1.3555E-5s
=== Warmed up ===
0.033086572s
0.014001648s
0.013213254s
60.06% faster from function
5.63% faster from variable
- Output for 8.0.2
- 0.001261704s
1.4567E-5s
1.3746E-5s
=== Warmed up ===
0.032395501s
0.015930618s
0.013247269s
59.11% faster from function
16.84% faster from variable
- Output for 8.0.1
- 3.6739E-5s
0.001225837s
1.3946E-5s
=== Warmed up ===
0.033270518s
0.013852578s
0.01347665s
59.49% faster from function
2.71% faster from variable
preferences:
78.26 ms | 559 KiB | 5 Q