3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Lavoiesl\PhpBenchmark; class Profiler { private $start_memory = 0; private $max_memory = 0; private $start_time = null; private $end_time = null; public function start() { $this->start_memory = $this->max_memory = memory_get_usage(true); $this->start_time = microtime(true); register_tick_function( array( $this, "tick" ) ); } public function tick() { $this->max_memory = max($this->max_memory, memory_get_usage(true)); } public function stop() { $this->tick(); $this->end_time = microtime(true); unregister_tick_function( array( $this, "tick" ) ); } function getMemoryUsage() { return $this->max_memory - $this->start_memory; } function getTime() { return $this->end_time - $this->start_time; } } abstract class AbstractTest { /** * @var string */ private $name; private $profiler; public function __construct($name) { $this->name = $name; $this->profiler = new Profiler; } public function getName() { return $this->name; } public function run($n = 1) { $this->prepare(); gc_collect_cycles(); // clear memory before start $this->profiler->start(); for ($i=0; $i < $n; $i++) { // Store the result so it appears in memory profiling $result = $this->execute(); unset($result); } $this->profiler->stop(); $results = array( 'time' => $this->profiler->getTime(), 'memory' => $this->profiler->getMemoryUsage(), 'n' => $n, ); $this->cleanup(); return $results; } protected function prepare() { } abstract protected function execute(); protected function cleanup() { } public function guessCount($max_seconds = 1) { $this->run(); // warmup $once = $this->run(); if ($once['time'] >= $max_seconds) { return 1; } else { return round($max_seconds / $once['time']); } } } class SimpleTest extends AbstractTest { /** * @var \Closure */ private $prepare = null; /** * @var \Closure */ private $execute; /** * @var \Closure */ private $cleanup = null; public function __construct($name, \Closure $execute) { parent::__construct($name); $this->execute = $execute; } public function setPrepare(\Closure $prepare) { $this->prepare = $prepare; return $this; } protected function prepare() { if ($prepare = $this->prepare) { $prepare(); } } protected function execute() { return call_user_func($this->execute); } public function setCleanup(\Closure $cleanup) { $this->cleanup = $cleanup; return $this; } protected function cleanup() { if ($cleanup = $this->cleanup) { $cleanup(); } } } class Benchmark { /** * @var array [Test] */ private $tests = array(); private $n = null; private $base_results; public function addTest(AbstractTest $test) { $this->tests[$test->getName()] = $test; } /** * Utility method to create tests on the fly * You may chain the test: * * @param string $name * @param \Closure $closure function to execute * @return SimpleTest */ public function add($name, \Closure $closure) { $test = new SimpleTest($name, $closure); $this->addTest($test); return $test; } /** * Runs an empty test to determine the benchmark overhead and run each test once */ private function warmup() { $warmup = new SimpleTest('warmup', function(){}); $warmup->run(); foreach ($this->tests as $test) { $test->run(); } $this->base_results = $warmup->run($this->n); } public function run($output = true) { $results = array(); if (null === $this->n) { $this->guessCount(2); // aim for around 2 seconds per test } if ($output) { echo "Running tests {$this->n} times.\n"; } $this->warmup(); $i = 0; foreach ($this->tests as $name => $test) { if ($output) { echo "Testing ".++$i."/".count($this->tests)." : $name\r"; } $results[$name] = $test->run($this->n); } if ($output) { echo "\n\n"; self::outputTable(self::formatResults($results)); } return $results; } public function setCount($n) { $this->n = $n; } /** * Average the guessCount of each test, determining the best n * * @param float $max_seconds * @return int */ public function guessCount($max_seconds) { if (!$this->tests) { throw new \RuntimeException('No test in Benchmark.'); } $n = INF; foreach ($this->tests as $test) { $n = min($n, $test->guessCount($max_seconds)); } return $this->n = Util::round($n); } /** * Output results in columns, padding right if values are string, left if numeric * * @param array $lines array(array('Name' => 'Value')); * @param integer $padding space between columns */ public static function outputTable(array $lines, $padding = 3) { if (!$lines) { return; } $pad = function ($string, $width) use ($padding) { if ($width > 0) { return str_pad($string, $width, " ") . str_repeat(' ' , $padding); } else { return str_pad($string, -$width, " ", STR_PAD_LEFT) . str_repeat(' ' , $padding); } }; // init width with keys' length $cols = array_combine(array_keys($lines[0]), array_map('strlen', array_keys($lines[0]))); foreach ($cols as $col => $width) { foreach ($lines as $line) { $width = max($width, strlen($line[$col])); } // pad left if numeric if (preg_match('/^[0-9]/', $line[$col])) { $width = -$width; } echo $pad($col, $width); $cols[$col] = $width; } echo "\n"; foreach ($lines as $line) { foreach ($cols as $col => $width) { echo $pad($line[$col], $width); } echo "\n"; } } /** * Format the results, rounding numbers, showing difference percentages * and removing a flat time based on the benchmark overhead * * @param array $results array($name => array('time' => 1.0)) * @return array array(array('Test' => $name, 'Time' => '1000 ms', 'Perc' => '100 %')) */ public function formatResults(array $results) { uasort($results, function($a, $b) { if ($a['time'] == $b['time']) return 0; else return ($a['time'] < $b['time']) ? -1 : 1; }); $min_time = INF; $min_memory = INF; foreach ($results as $name => $result) { $time = $result['time']; $time -= $this->base_results['time']; // Substract base_time $time *= 1000; // Convert to ms $time = round($time); $time = max(1, $time); // min 1 ms $min_time = min($min_time, $time); $results[$name]['time'] = $time; $min_memory = min($min_memory, $results[$name]['memory']); } $output = array(); foreach ($results as $name => $result) { $output[] = array( 'Test' => $name, 'Time' => $result['time'] . ' ms', 'Time (%)' => Util::relativePerc($min_time, $result['time']), 'Memory' => Util::convertToSI($result['memory']), 'Memory (%)' => Util::relativePerc($min_memory, $result['memory']), ); } return $output; } } class Util { public static function round($number, $significant = 0) { $order = floor(log($number) / log(10)); return round($number / pow(10, $order), $significant) * pow(10, $order); } /** * Converts 1024 to 1K, etc. * * @param double $number i.e.: 1280 * @param integer $precision i.e.: 1.25 for precision = 2 * @param string $unit suffix of the unit, may be empty * @param integer $factor change base to 1000 or 1024 * @return string i.e.: 1.25 kB */ public static function convertToSI($number, $precision = 2, $unit = 'B', $factor = 1024) { static $sizes = array( '-3' => 'n', '-2' => 'ยต', '-1' => 'm', '0' => '', '1' => 'k', '2' => 'M', '3' => 'G', '4' => 'T' ); $scale = $number == 0 ? 0 : floor(log($number, $factor)); return round($number / pow($factor, $scale), $precision) . ' ' . $sizes[$scale] . $unit = 'B'; } public static function relativePerc($min, $value) { if ($min == 0 || $min == $value) { return ''; } else { return round(($value - $min) / $min * 100) . ' %'; } } } $benchmark = new Benchmark; function multiexplode ($delimiters,$string) { $ready = str_replace($delimiters, $delimiters[0], $string); $launch = explode($delimiters[0], $ready); return $launch; } function homemadeexplode($splitter, $str) { $return = []; if (is_array($splitter) == true) { foreach ($splitter as $sp) { $str = homemadeexplode($sp, $str); } $return = $str; } else { if (is_array($str) == true) { foreach ($str as $st) { $tmp = explode($splitter, $st); $return = array_merge($return, $tmp); } } else { $return = explode($splitter, $str); } } return $return; } $text = "here is a sample: this text, and this will be exploded. this also | this one too :)"; $benchmark->add('multiexplode', function() use($text) { return multiexplode( [",",".","|",":"], $text); }); $benchmark->add('homemadeExplode', function() use($text) { return homemadeexplode([",",".","|",":"], $text); }); $benchmark->add('preg_split', function() use($text) { return preg_split( '/[,.|:]/', $text); }); $benchmark->add('mb_split', function() use($text) { return mb_split( '[,.|:]', $text); }); $benchmark->setCount(50000); $benchmark->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  (null)
number of ops:  34
compiled vars:  !0 = $benchmark, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  420     0  E >   NEW                                              $2      'Lavoiesl%5CPhpBenchmark%5CBenchmark'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
  451     3        ASSIGN                                                   !1, 'here+is+a+sample%3A+this+text%2C+and+this+will+be+exploded.+this+also+%7C+this+one+too+%3A%29'
  453     4        INIT_METHOD_CALL                                         !0, 'add'
          5        SEND_VAL_EX                                              'multiexplode'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A453%243'
          7        BIND_LEXICAL                                             ~6, !1
          8        SEND_VAL_EX                                              ~6
          9        DO_FCALL                                      0          
  454    10        INIT_METHOD_CALL                                         !0, 'add'
         11        SEND_VAL_EX                                              'homemadeExplode'
         12        DECLARE_LAMBDA_FUNCTION                                  '%00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A454%244'
         13        BIND_LEXICAL                                             ~8, !1
         14        SEND_VAL_EX                                              ~8
         15        DO_FCALL                                      0          
  455    16        INIT_METHOD_CALL                                         !0, 'add'
         17        SEND_VAL_EX                                              'preg_split'
         18        DECLARE_LAMBDA_FUNCTION                                  '%00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A455%245'
         19        BIND_LEXICAL                                             ~10, !1
         20        SEND_VAL_EX                                              ~10
         21        DO_FCALL                                      0          
  456    22        INIT_METHOD_CALL                                         !0, 'add'
         23        SEND_VAL_EX                                              'mb_split'
         24        DECLARE_LAMBDA_FUNCTION                                  '%00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A456%246'
         25        BIND_LEXICAL                                             ~12, !1
         26        SEND_VAL_EX                                              ~12
         27        DO_FCALL                                      0          
  458    28        INIT_METHOD_CALL                                         !0, 'setCount'
         29        SEND_VAL_EX                                              50000
         30        DO_FCALL                                      0          
  459    31        INIT_METHOD_CALL                                         !0, 'run'
         32        DO_FCALL                                      0          
         33      > RETURN                                                   1

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A215%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  215     0  E > > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A215%240

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A293%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  32
compiled vars:  !0 = $string, !1 = $width, !2 = $padding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  293     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
  294     3        IS_SMALLER                                               0, !1
          4      > JMPZ                                                     ~3, ->17
  295     5    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cstr_pad'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        SEND_VAL_EX                                              '+'
          9        DO_FCALL                                      0  $4      
         10        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cstr_repeat'
         11        SEND_VAL_EX                                              '+'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0  $5      
         14        CONCAT                                           ~6      $4, $5
         15      > RETURN                                                   ~6
         16*       JMP                                                      ->31
  297    17    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cstr_pad'
         18        SEND_VAR_EX                                              !0
         19        MUL                                              ~7      !1, -1
         20        SEND_VAL_EX                                              ~7
         21        SEND_VAL_EX                                              '+'
         22        FETCH_CONSTANT                                   ~8      'Lavoiesl%5CPhpBenchmark%5CSTR_PAD_LEFT'
         23        SEND_VAL_EX                                              ~8
         24        DO_FCALL                                      0  $9      
         25        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cstr_repeat'
         26        SEND_VAL_EX                                              '+'
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0  $10     
         29        CONCAT                                           ~11     $9, $10
         30      > RETURN                                                   ~11
  299    31*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A293%241

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A336%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  17
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  336     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  337     2        FETCH_DIM_R                                      ~2      !0, 'time'
          3        FETCH_DIM_R                                      ~3      !1, 'time'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->8
  338     6    > > RETURN                                                   0
          7*       JMP                                                      ->16
  340     8    >   FETCH_DIM_R                                      ~5      !0, 'time'
          9        FETCH_DIM_R                                      ~6      !1, 'time'
         10        IS_SMALLER                                               ~5, ~6
         11      > JMPZ                                                     ~7, ->14
         12    >   QM_ASSIGN                                        ~8      -1
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~8      1
         15    > > RETURN                                                   ~8
  341    16*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A336%242

Function lavoiesl%5Cphpbenchmark%5Cmultiexplode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\multiexplode
number of ops:  19
compiled vars:  !0 = $delimiters, !1 = $string, !2 = $ready, !3 = $launch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  422     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  424     2        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cstr_replace'
          3        SEND_VAR_EX                                              !0
          4        CHECK_FUNC_ARG                                           
          5        FETCH_DIM_FUNC_ARG                               $4      !0, 0
          6        SEND_FUNC_ARG                                            $4
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !2, $5
  425    10        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cexplode'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $7      !0, 0
         13        SEND_FUNC_ARG                                            $7
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $8      
         16        ASSIGN                                                   !3, $8
  426    17      > RETURN                                                   !3
  427    18*     > RETURN                                                   null

End of function lavoiesl%5Cphpbenchmark%5Cmultiexplode

Function lavoiesl%5Cphpbenchmark%5Chomemadeexplode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 39
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 37
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 37
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\homemadeexplode
number of ops:  46
compiled vars:  !0 = $splitter, !1 = $str, !2 = $return, !3 = $sp, !4 = $st, !5 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  429     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  431     2        ASSIGN                                                   !2, <array>
  432     3        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cis_array'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $7      
          6        BOOL                                             ~8      $7
          7      > JMPZ                                                     ~8, ->19
  433     8    > > FE_RESET_R                                       $9      !0, ->16
          9    > > FE_FETCH_R                                               $9, !3, ->16
  434    10    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Chomemadeexplode'
         11        SEND_VAR_EX                                              !3
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !1, $10
  433    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $9
  436    17        ASSIGN                                                   !2, !1
         18      > JMP                                                      ->44
  438    19    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cis_array'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $13     
         22        BOOL                                             ~14     $13
         23      > JMPZ                                                     ~14, ->39
  439    24    > > FE_RESET_R                                       $15     !1, ->37
         25    > > FE_FETCH_R                                               $15, !4, ->37
  440    26    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cexplode'
         27        SEND_VAR_EX                                              !0
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0  $16     
         30        ASSIGN                                                   !5, $16
  441    31        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Carray_merge'
         32        SEND_VAR_EX                                              !2
         33        SEND_VAR_EX                                              !5
         34        DO_FCALL                                      0  $18     
         35        ASSIGN                                                   !2, $18
  439    36      > JMP                                                      ->25
         37    >   FE_FREE                                                  $15
         38      > JMP                                                      ->44
  444    39    >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cexplode'
         40        SEND_VAR_EX                                              !0
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $20     
         43        ASSIGN                                                   !2, $20
  447    44    > > RETURN                                                   !2
  448    45*     > RETURN                                                   null

End of function lavoiesl%5Cphpbenchmark%5Chomemadeexplode

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A453%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  7
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  453     0  E >   BIND_STATIC                                              !0
          1        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmultiexplode'
          2        SEND_VAL_EX                                              <array>
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A453%243

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A454%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  7
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  454     0  E >   BIND_STATIC                                              !0
          1        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Chomemadeexplode'
          2        SEND_VAL_EX                                              <array>
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A454%244

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A455%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  7
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  455     0  E >   BIND_STATIC                                              !0
          1        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cpreg_split'
          2        SEND_VAL_EX                                              '%2F%5B%2C.%7C%3A%5D%2F'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A455%245

Function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A456%246:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  Lavoiesl\PhpBenchmark\{closure}
number of ops:  7
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  456     0  E >   BIND_STATIC                                              !0
          1        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmb_split'
          2        SEND_VAL_EX                                              '%5B%2C.%7C%3A%5D'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00lavoiesl%5Cphpbenchmark%5C%7Bclosure%7D%2Fin%2Fs6vfi%3A456%246

Class Lavoiesl\PhpBenchmark\Profiler:
Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  start
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmemory_get_usage'
          1        SEND_VAL_EX                                              <true>
          2        DO_FCALL                                      0  $2      
          3        ASSIGN_OBJ                                       ~1      'max_memory'
          4        OP_DATA                                                  $2
          5        ASSIGN_OBJ                                               'start_memory'
          6        OP_DATA                                                  ~1
   18     7        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmicrotime'
          8        SEND_VAL_EX                                              <true>
          9        DO_FCALL                                      0  $4      
         10        ASSIGN_OBJ                                               'start_time'
         11        OP_DATA                                                  $4
   20    12        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cregister_tick_function'
         13        FETCH_THIS                                       ~5      
         14        INIT_ARRAY                                       ~6      ~5
         15        ADD_ARRAY_ELEMENT                                ~6      'tick'
         16        SEND_VAL_EX                                              ~6
         17        DO_FCALL                                      0          
   21    18      > RETURN                                                   null

End of function start

Function tick:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  tick
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmax'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'max_memory'
          3        SEND_FUNC_ARG                                            $1
          4        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmemory_get_usage'
          5        SEND_VAL_EX                                              <true>
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR_NO_REF_EX                                       $2
          8        DO_FCALL                                      0  $3      
          9        ASSIGN_OBJ                                               'max_memory'
         10        OP_DATA                                                  $3
   26    11      > RETURN                                                   null

End of function tick

Function stop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  stop
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_METHOD_CALL                                         'tick'
          1        DO_FCALL                                      0          
   31     2        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cmicrotime'
          3        SEND_VAL_EX                                              <true>
          4        DO_FCALL                                      0  $2      
          5        ASSIGN_OBJ                                               'end_time'
          6        OP_DATA                                                  $2
   33     7        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cunregister_tick_function'
          8        FETCH_THIS                                       ~3      
          9        INIT_ARRAY                                       ~4      ~3
         10        ADD_ARRAY_ELEMENT                                ~4      'tick'
         11        SEND_VAL_EX                                              ~4
         12        DO_FCALL                                      0          
   34    13      > RETURN                                                   null

End of function stop

Function getmemoryusage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  getMemoryUsage
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_OBJ_R                                      ~0      'max_memory'
          1        FETCH_OBJ_R                                      ~1      'start_memory'
          2        SUB                                              ~2      ~0, ~1
          3      > RETURN                                                   ~2
   39     4*     > RETURN                                                   null

End of function getmemoryusage

Function gettime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  getTime
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_OBJ_R                                      ~0      'end_time'
          1        FETCH_OBJ_R                                      ~1      'start_time'
          2        SUB                                              ~2      ~0, ~1
          3      > RETURN                                                   ~2
   44     4*     > RETURN                                                   null

End of function gettime

End of class Lavoiesl\PhpBenchmark\Profiler.

Class Lavoiesl\PhpBenchmark\AbstractTest:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  __construct
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   59     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   60     3        NEW                                              $3      'Lavoiesl%5CPhpBenchmark%5CProfiler'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'profiler'
          6        OP_DATA                                                  $3
   61     7      > RETURN                                                   null

End of function __construct

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/s6vfi
function name:  getName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1      > RETURN                                                   ~0
   66     2*     > RETURN                                                   null

End of function getname

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 10
Branch analysis from position: 17
Branch analysis from position: 10
filename:       /in/s6vfi
function name:  run
number of ops:  34
compiled vars:  !0 = $n, !1 = $i, !2 = $result, !3 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV_INIT                                        !0      1
   70     1        INIT_METHOD_CALL                                         'prepare'
          2        DO_FCALL                                      0          
   72     3        INIT_NS_FCALL_BY_NAME                                    'Lavoiesl%5CPhpBenchmark%5Cgc_collect_cycles'
          4        DO_FCALL                                      0          
   74     5        FETCH_OBJ_R                                      ~6      'profiler'
          6        INIT_METHOD_CALL                                         ~6, 'start'
          7        DO_FCALL                                      0          
   76     8        ASSIGN                                                   !1, 0
          9      > JMP                                                      ->15
   78    10    >   INIT_METHOD_CALL                                         'execute'
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !2, $9
   79    13        UNSET_CV                                                 !2
   76    14        PRE_INC           

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.66 ms | 1430 KiB | 44 Q