Example #1
0
function benchLoops(array $tests)
{
    $loops = array('StreamSelectLoop', 'LibEventLoop', 'LibEvLoop');
    foreach ($tests as $testName => $test) {
        foreach ($loops as $loopName) {
            $loopClass = "React\\EventLoop\\{$loopName}";
            $loop = new $loopClass();
            $bench = new Bench();
            $bench->start();
            $test($loop);
            $bench->printSnap("{$loopName}: {$testName}");
        }
        printf("----------------------------------------\n");
    }
}
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $this->test = str_repeat($this->test, 1);
     $bench_non_cached = new Bench();
     $bench_non_cached->start();
     $this->run_non_cached_parsing();
     $bench_non_cached->stop();
     $bench_cached = new Bench();
     $bench_cached->start();
     $this->run_cached_parsing();
     $bench_cached->stop();
     $this->view->put_all(array('RESULT' => StringVars::replace_vars($this->lang['string_template.result'], array('non_cached_time' => $bench_non_cached->to_string(5), 'cached_time' => $bench_cached->to_string(5), 'string_length' => strlen($this->test)))));
     return $this->generate_response();
 }
<?php

// Description: Serialize scalar int
require_once 'bench.php';
$b = new Bench('serialize-scalar-int');
$var = 1;
for ($i = 0; $i < 40; $i++) {
    $b->start();
    for ($j = 0; $j < 3500000; $j++) {
        $ser = igbinary_serialize($var);
    }
    $b->stop($j);
    $b->write();
}
Example #4
0
 /**
  * Reset timer.
  *
  * @return void;
  */
 public static function reset()
 {
     self::$marks = array();
     self::$start = null;
     self::$stop = null;
 }
Example #5
0
 /**
  * Inits the bench
  */
 public static function init_bench()
 {
     self::$bench = new Bench();
     self::$bench->start();
 }
Example #6
0
function bench_string($string_size, $string_iteration)
{
    echo '<h1>String</h1>';
    $string = '';
    for ($i = 0; $i < $string_size; $i++) {
        $string .= '.';
    }
    $bench = new Bench();
    $bench->start();
    for ($i = 0; $i < $string_iteration; $i++) {
        string_by_ref($string);
    }
    $bench->stop();
    echo 'Ref: ' . $bench->to_string() . '<hr />';
    $bench = new Bench();
    $bench->start();
    for ($i = 0; $i < $string_iteration; $i++) {
        string_by_cp($string);
    }
    $bench->stop();
    echo 'Copy: ' . $bench->to_string() . '<hr />';
}