3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); /* |-------------------------------------------------------------------------- | Benchmark: | | 1. Dynamic call: | $instance->$method(...$args) | | 2. Reflection: | ReflectionMethod::invoke() | | 3. Cached first-class callable: | self::method(...) | | 4. Cached closure + Closure::call() | | This benchmark is specifically useful for: | - AOP | - proxy dispatch | - interceptor systems | - generated wrappers | |-------------------------------------------------------------------------- */ final class Bench { private int $value = 42; public function targetMethod(int $a, int $b): int { return $this->value + $a + $b; } public function run(int $iterations = 5_000_000): void { $method = 'targetMethod'; $args = [10, 20]; echo "Iterations: {$iterations}\n"; echo "Object ID : " . spl_object_id($this) . "\n"; echo str_repeat('-', 70) . "\n"; /* * Warmup (important for fair benchmark) */ for ($i = 0; $i < 10000; $i++) { $this->targetMethod(1, 2); } /* * Reflection prepared once */ $reflection = new ReflectionMethod(self::class, 'targetMethod'); /* * First-class callable prepared once * * You can test BOTH variants: * * Variant A: * $cachedClosure = $this->targetMethod(...); * * Variant B: * $cachedClosure = self::targetMethod(...); * * (both valid inside object context) */ $cachedClosure = self::targetMethod(...); /* * Another object for Closure::call() */ $another = new self(); /* * Prevent optimizer from eliminating calls */ $checksum = 0; /* |-------------------------------------------------------------------------- | 1. Dynamic method call |-------------------------------------------------------------------------- */ $start = hrtime(true); for ($i = 0; $i < $iterations; $i++) { $checksum += $this->$method(...$args); } $dynamicTime = hrtime(true) - $start; /* |-------------------------------------------------------------------------- | 2. ReflectionMethod::invoke() |-------------------------------------------------------------------------- */ $start = hrtime(true); for ($i = 0; $i < $iterations; $i++) { $checksum += $reflection->invoke($this, ...$args); } $reflectionTime = hrtime(true) - $start; /* |-------------------------------------------------------------------------- | 3. Cached closure direct call |-------------------------------------------------------------------------- */ $start = hrtime(true); for ($i = 0; $i < $iterations; $i++) { $checksum += $cachedClosure(...$args); } $closureTime = hrtime(true) - $start; /* |-------------------------------------------------------------------------- | 4. Cached closure + Closure::call() |-------------------------------------------------------------------------- */ $start = hrtime(true); for ($i = 0; $i < $iterations; $i++) { $checksum += $cachedClosure->call($another, ...$args); } $callTime = hrtime(true) - $start; echo "Checksum (ignore): {$checksum}\n"; echo str_repeat('-', 70) . "\n"; $this->printResult('1. Dynamic $obj->$method()', $dynamicTime, $iterations); $this->printResult('2. ReflectionMethod::invoke()', $reflectionTime, $iterations); $this->printResult('3. Cached closure direct', $closureTime, $iterations); $this->printResult('4. Closure->call()', $callTime, $iterations); echo str_repeat('-', 70) . "\n"; echo "Lower is better\n"; } private function printResult( string $label, int $nanoseconds, int $iterations ): void { $ms = $nanoseconds / 1_000_000; $nsPerOp = $nanoseconds / $iterations; printf( "%-35s %12.3f ms (%8.2f ns/op)\n", $label, $ms, $nsPerOp ); } } (new Bench())->run();
Output for 8.5.3
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 310.478 ms ( 62.10 ns/op) 2. ReflectionMethod::invoke() 282.810 ms ( 56.56 ns/op) 3. Cached closure direct 194.845 ms ( 38.97 ns/op) 4. Closure->call() 326.481 ms ( 65.30 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.5.2
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 295.946 ms ( 59.19 ns/op) 2. ReflectionMethod::invoke() 282.514 ms ( 56.50 ns/op) 3. Cached closure direct 223.691 ms ( 44.74 ns/op) 4. Closure->call() 321.964 ms ( 64.39 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.5.1
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 296.022 ms ( 59.20 ns/op) 2. ReflectionMethod::invoke() 285.328 ms ( 57.07 ns/op) 3. Cached closure direct 197.509 ms ( 39.50 ns/op) 4. Closure->call() 311.669 ms ( 62.33 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.5.0
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 332.230 ms ( 66.45 ns/op) 2. ReflectionMethod::invoke() 281.217 ms ( 56.24 ns/op) 3. Cached closure direct 191.255 ms ( 38.25 ns/op) 4. Closure->call() 320.409 ms ( 64.08 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.18
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 293.050 ms ( 58.61 ns/op) 2. ReflectionMethod::invoke() 273.594 ms ( 54.72 ns/op) 3. Cached closure direct 183.024 ms ( 36.60 ns/op) 4. Closure->call() 331.499 ms ( 66.30 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.17
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 293.238 ms ( 58.65 ns/op) 2. ReflectionMethod::invoke() 277.364 ms ( 55.47 ns/op) 3. Cached closure direct 192.793 ms ( 38.56 ns/op) 4. Closure->call() 321.032 ms ( 64.21 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.16
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 292.137 ms ( 58.43 ns/op) 2. ReflectionMethod::invoke() 274.336 ms ( 54.87 ns/op) 3. Cached closure direct 188.638 ms ( 37.73 ns/op) 4. Closure->call() 310.830 ms ( 62.17 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.15
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 303.260 ms ( 60.65 ns/op) 2. ReflectionMethod::invoke() 298.127 ms ( 59.63 ns/op) 3. Cached closure direct 185.052 ms ( 37.01 ns/op) 4. Closure->call() 326.212 ms ( 65.24 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.14
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 276.121 ms ( 55.22 ns/op) 2. ReflectionMethod::invoke() 294.600 ms ( 58.92 ns/op) 3. Cached closure direct 192.162 ms ( 38.43 ns/op) 4. Closure->call() 338.646 ms ( 67.73 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.13
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 283.860 ms ( 56.77 ns/op) 2. ReflectionMethod::invoke() 271.810 ms ( 54.36 ns/op) 3. Cached closure direct 197.220 ms ( 39.44 ns/op) 4. Closure->call() 319.677 ms ( 63.94 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.12
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 312.538 ms ( 62.51 ns/op) 2. ReflectionMethod::invoke() 293.821 ms ( 58.76 ns/op) 3. Cached closure direct 202.873 ms ( 40.57 ns/op) 4. Closure->call() 336.541 ms ( 67.31 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.11
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 272.990 ms ( 54.60 ns/op) 2. ReflectionMethod::invoke() 290.682 ms ( 58.14 ns/op) 3. Cached closure direct 189.306 ms ( 37.86 ns/op) 4. Closure->call() 324.504 ms ( 64.90 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.10
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 275.429 ms ( 55.09 ns/op) 2. ReflectionMethod::invoke() 269.461 ms ( 53.89 ns/op) 3. Cached closure direct 194.722 ms ( 38.94 ns/op) 4. Closure->call() 314.649 ms ( 62.93 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.9
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 297.159 ms ( 59.43 ns/op) 2. ReflectionMethod::invoke() 292.203 ms ( 58.44 ns/op) 3. Cached closure direct 197.050 ms ( 39.41 ns/op) 4. Closure->call() 316.105 ms ( 63.22 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.8
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 290.896 ms ( 58.18 ns/op) 2. ReflectionMethod::invoke() 298.496 ms ( 59.70 ns/op) 3. Cached closure direct 201.863 ms ( 40.37 ns/op) 4. Closure->call() 314.434 ms ( 62.89 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.7
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 280.308 ms ( 56.06 ns/op) 2. ReflectionMethod::invoke() 278.967 ms ( 55.79 ns/op) 3. Cached closure direct 195.804 ms ( 39.16 ns/op) 4. Closure->call() 315.224 ms ( 63.04 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.6
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 277.916 ms ( 55.58 ns/op) 2. ReflectionMethod::invoke() 277.796 ms ( 55.56 ns/op) 3. Cached closure direct 189.892 ms ( 37.98 ns/op) 4. Closure->call() 314.217 ms ( 62.84 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.5
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 271.638 ms ( 54.33 ns/op) 2. ReflectionMethod::invoke() 277.377 ms ( 55.48 ns/op) 3. Cached closure direct 194.851 ms ( 38.97 ns/op) 4. Closure->call() 312.173 ms ( 62.43 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.4
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 286.756 ms ( 57.35 ns/op) 2. ReflectionMethod::invoke() 276.087 ms ( 55.22 ns/op) 3. Cached closure direct 192.081 ms ( 38.42 ns/op) 4. Closure->call() 321.855 ms ( 64.37 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.3
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 288.057 ms ( 57.61 ns/op) 2. ReflectionMethod::invoke() 290.931 ms ( 58.19 ns/op) 3. Cached closure direct 193.567 ms ( 38.71 ns/op) 4. Closure->call() 330.932 ms ( 66.19 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.2
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 278.118 ms ( 55.62 ns/op) 2. ReflectionMethod::invoke() 289.197 ms ( 57.84 ns/op) 3. Cached closure direct 196.869 ms ( 39.37 ns/op) 4. Closure->call() 321.635 ms ( 64.33 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.4.1
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 273.199 ms ( 54.64 ns/op) 2. ReflectionMethod::invoke() 274.154 ms ( 54.83 ns/op) 3. Cached closure direct 204.605 ms ( 40.92 ns/op) 4. Closure->call() 323.298 ms ( 64.66 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.30
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 289.151 ms ( 57.83 ns/op) 2. ReflectionMethod::invoke() 289.381 ms ( 57.88 ns/op) 3. Cached closure direct 183.685 ms ( 36.74 ns/op) 4. Closure->call() 313.463 ms ( 62.69 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.29
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 304.739 ms ( 60.95 ns/op) 2. ReflectionMethod::invoke() 285.223 ms ( 57.04 ns/op) 3. Cached closure direct 183.432 ms ( 36.69 ns/op) 4. Closure->call() 345.632 ms ( 69.13 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.28
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 307.823 ms ( 61.56 ns/op) 2. ReflectionMethod::invoke() 274.585 ms ( 54.92 ns/op) 3. Cached closure direct 191.336 ms ( 38.27 ns/op) 4. Closure->call() 313.376 ms ( 62.68 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.27
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 283.280 ms ( 56.66 ns/op) 2. ReflectionMethod::invoke() 273.793 ms ( 54.76 ns/op) 3. Cached closure direct 199.810 ms ( 39.96 ns/op) 4. Closure->call() 303.280 ms ( 60.66 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.26
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 294.030 ms ( 58.81 ns/op) 2. ReflectionMethod::invoke() 269.619 ms ( 53.92 ns/op) 3. Cached closure direct 199.960 ms ( 39.99 ns/op) 4. Closure->call() 316.307 ms ( 63.26 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.25
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 264.888 ms ( 52.98 ns/op) 2. ReflectionMethod::invoke() 284.997 ms ( 57.00 ns/op) 3. Cached closure direct 193.332 ms ( 38.67 ns/op) 4. Closure->call() 309.464 ms ( 61.89 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.24
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 265.195 ms ( 53.04 ns/op) 2. ReflectionMethod::invoke() 283.847 ms ( 56.77 ns/op) 3. Cached closure direct 209.297 ms ( 41.86 ns/op) 4. Closure->call() 312.571 ms ( 62.51 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.23
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 272.915 ms ( 54.58 ns/op) 2. ReflectionMethod::invoke() 279.818 ms ( 55.96 ns/op) 3. Cached closure direct 189.509 ms ( 37.90 ns/op) 4. Closure->call() 313.417 ms ( 62.68 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.22
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 276.117 ms ( 55.22 ns/op) 2. ReflectionMethod::invoke() 270.049 ms ( 54.01 ns/op) 3. Cached closure direct 195.858 ms ( 39.17 ns/op) 4. Closure->call() 316.251 ms ( 63.25 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.21
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 263.752 ms ( 52.75 ns/op) 2. ReflectionMethod::invoke() 277.898 ms ( 55.58 ns/op) 3. Cached closure direct 180.673 ms ( 36.13 ns/op) 4. Closure->call() 325.497 ms ( 65.10 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.20
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 278.271 ms ( 55.65 ns/op) 2. ReflectionMethod::invoke() 281.857 ms ( 56.37 ns/op) 3. Cached closure direct 202.380 ms ( 40.48 ns/op) 4. Closure->call() 320.743 ms ( 64.15 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.19
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 305.350 ms ( 61.07 ns/op) 2. ReflectionMethod::invoke() 283.460 ms ( 56.69 ns/op) 3. Cached closure direct 236.880 ms ( 47.38 ns/op) 4. Closure->call() 312.140 ms ( 62.43 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.18
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 270.190 ms ( 54.04 ns/op) 2. ReflectionMethod::invoke() 269.822 ms ( 53.96 ns/op) 3. Cached closure direct 186.544 ms ( 37.31 ns/op) 4. Closure->call() 326.635 ms ( 65.33 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.17
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 280.336 ms ( 56.07 ns/op) 2. ReflectionMethod::invoke() 279.028 ms ( 55.81 ns/op) 3. Cached closure direct 193.381 ms ( 38.68 ns/op) 4. Closure->call() 315.555 ms ( 63.11 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.16
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 278.465 ms ( 55.69 ns/op) 2. ReflectionMethod::invoke() 269.019 ms ( 53.80 ns/op) 3. Cached closure direct 188.097 ms ( 37.62 ns/op) 4. Closure->call() 320.212 ms ( 64.04 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.15
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 267.712 ms ( 53.54 ns/op) 2. ReflectionMethod::invoke() 267.738 ms ( 53.55 ns/op) 3. Cached closure direct 183.262 ms ( 36.65 ns/op) 4. Closure->call() 307.250 ms ( 61.45 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.14
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 282.084 ms ( 56.42 ns/op) 2. ReflectionMethod::invoke() 264.568 ms ( 52.91 ns/op) 3. Cached closure direct 192.207 ms ( 38.44 ns/op) 4. Closure->call() 307.920 ms ( 61.58 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.13
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 263.394 ms ( 52.68 ns/op) 2. ReflectionMethod::invoke() 270.021 ms ( 54.00 ns/op) 3. Cached closure direct 184.535 ms ( 36.91 ns/op) 4. Closure->call() 308.888 ms ( 61.78 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.12
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 263.979 ms ( 52.80 ns/op) 2. ReflectionMethod::invoke() 272.174 ms ( 54.43 ns/op) 3. Cached closure direct 179.886 ms ( 35.98 ns/op) 4. Closure->call() 312.555 ms ( 62.51 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.11
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 265.484 ms ( 53.10 ns/op) 2. ReflectionMethod::invoke() 268.749 ms ( 53.75 ns/op) 3. Cached closure direct 187.935 ms ( 37.59 ns/op) 4. Closure->call() 299.452 ms ( 59.89 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.10
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 268.923 ms ( 53.78 ns/op) 2. ReflectionMethod::invoke() 268.988 ms ( 53.80 ns/op) 3. Cached closure direct 184.658 ms ( 36.93 ns/op) 4. Closure->call() 319.218 ms ( 63.84 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.9
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 291.946 ms ( 58.39 ns/op) 2. ReflectionMethod::invoke() 273.107 ms ( 54.62 ns/op) 3. Cached closure direct 200.048 ms ( 40.01 ns/op) 4. Closure->call() 306.367 ms ( 61.27 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.8
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 264.215 ms ( 52.84 ns/op) 2. ReflectionMethod::invoke() 265.706 ms ( 53.14 ns/op) 3. Cached closure direct 190.945 ms ( 38.19 ns/op) 4. Closure->call() 310.120 ms ( 62.02 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.7
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 267.362 ms ( 53.47 ns/op) 2. ReflectionMethod::invoke() 270.445 ms ( 54.09 ns/op) 3. Cached closure direct 187.020 ms ( 37.40 ns/op) 4. Closure->call() 329.229 ms ( 65.85 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.6
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 265.543 ms ( 53.11 ns/op) 2. ReflectionMethod::invoke() 275.879 ms ( 55.18 ns/op) 3. Cached closure direct 190.832 ms ( 38.17 ns/op) 4. Closure->call() 304.808 ms ( 60.96 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.5
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 264.368 ms ( 52.87 ns/op) 2. ReflectionMethod::invoke() 271.684 ms ( 54.34 ns/op) 3. Cached closure direct 180.536 ms ( 36.11 ns/op) 4. Closure->call() 304.319 ms ( 60.86 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.4
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 280.913 ms ( 56.18 ns/op) 2. ReflectionMethod::invoke() 276.473 ms ( 55.29 ns/op) 3. Cached closure direct 188.460 ms ( 37.69 ns/op) 4. Closure->call() 332.478 ms ( 66.50 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.3
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 292.598 ms ( 58.52 ns/op) 2. ReflectionMethod::invoke() 306.715 ms ( 61.34 ns/op) 3. Cached closure direct 204.272 ms ( 40.85 ns/op) 4. Closure->call() 372.857 ms ( 74.57 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.2
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 279.985 ms ( 56.00 ns/op) 2. ReflectionMethod::invoke() 283.080 ms ( 56.62 ns/op) 3. Cached closure direct 185.735 ms ( 37.15 ns/op) 4. Closure->call() 337.410 ms ( 67.48 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.1
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 282.562 ms ( 56.51 ns/op) 2. ReflectionMethod::invoke() 293.804 ms ( 58.76 ns/op) 3. Cached closure direct 186.323 ms ( 37.26 ns/op) 4. Closure->call() 365.047 ms ( 73.01 ns/op) ---------------------------------------------------------------------- Lower is better
Output for 8.3.0
Iterations: 5000000 Object ID : 1 ---------------------------------------------------------------------- Checksum (ignore): 1440000000 ---------------------------------------------------------------------- 1. Dynamic $obj->$method() 292.970 ms ( 58.59 ns/op) 2. ReflectionMethod::invoke() 274.781 ms ( 54.96 ns/op) 3. Cached closure direct 189.349 ms ( 37.87 ns/op) 4. Closure->call() 337.461 ms ( 67.49 ns/op) ---------------------------------------------------------------------- Lower is better

preferences:
65.64 ms | 735 KiB | 4 Q