Exemplo n.º 1
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $class = new DynamicClass();
         $class->testMethod();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Dynamic calls', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         (new DynamicClass())->testMethod();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Simple dynamic syntax', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         StaticClass::testMethod();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Static calls', Timer::get());
 }
 public function run()
 {
     $repeats = $this->getRepeats();
     $last_leave = '';
     $array = create3DAssocArray(3, 10);
     $leaves = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY);
     foreach ($leaves as $leave) {
         $last_leave = $leave;
     }
     $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         checkIterator($last_leave, $it);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Iterator', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         checkKeyIsInArray($last_leave, $array);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Custom func', Timer::get());
 }
Exemplo n.º 3
0
 public static final function run()
 {
     self::initCache();
     $repeats = self::getRepeats();
     $bar = new CliProgressBar($repeats);
     $key = md5('adfjkjkang');
     $data = range(0, 10);
     Cache::setAdapter(MemcacheAdapter::instance());
     Cache::set($key, $data);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         Cache::get($key);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('Memcache', Timer::get());
     $bar = new CliProgressBar($repeats);
     Cache::setAdapter(MemcachedAdapter::instance());
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         Cache::get($key);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('Memcached', Timer::get());
     Cache::clear();
 }
Exemplo n.º 4
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $var = true;
     $tmp = false;
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         if ($var) {
             $tmp = $var;
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('if', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $var and $tmp = $var;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('and', Timer::get());
 }
Exemplo n.º 5
0
 public function run()
 {
     $this->initCache();
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     $data = range(0, 99);
     Cache::setAdapter(MemcacheAdapter::instance());
     for ($i = 1; $i <= $repeats; ++$i) {
         $key = sha1(uniqid());
         Timer::start();
         Cache::set($key, $data);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Memcache', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     Cache::setAdapter(MemcachedAdapter::instance());
     for ($i = 1; $i <= $repeats; ++$i) {
         $key = sha1(uniqid());
         Timer::start();
         Cache::set($key, $data);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Memcached', Timer::get());
     Cache::clear();
 }
Exemplo n.º 6
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $filename1 = strtolower(uniqid('file')) . '.txt';
     $filename2 = strtolower(uniqid('file')) . '.txt';
     $string = genStrShuffle(100);
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $file = fopen($filename1, 'a+');
         flock($file, LOCK_EX);
         fwrite($file, $string);
         fclose($file);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('fwrite()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         file_put_contents($filename2, $string, FILE_APPEND | LOCK_EX);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('put_contents()', Timer::get());
     unlink($filename1);
     unlink($filename2);
 }
Exemplo n.º 7
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $prop_name = 'property';
     $prop_count = 30;
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = static::returnArray($prop_count, $prop_name);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('return array', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         $arr = static::createArray($prop_count, $prop_name);
         Timer::start();
         static::fillArray($arr, $prop_count, $prop_name);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('fill array', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         $obj = static::createObject($prop_count, $prop_name);
         Timer::start();
         static::fillObject($obj, $prop_count, $prop_name);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('fill object', Timer::get());
 }
Exemplo n.º 8
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $array = range(0, 10);
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $tmp = array_keys($array);
         foreach ($tmp as $value) {
         }
         Timer::stop();
         $bar->update($i);
     }
     unset($tmp, $value);
     $this->addResult('Outer function', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         foreach (array_keys($array) as $value) {
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Inner function', Timer::get());
 }
Exemplo n.º 9
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $string = 'This is test string';
     $needle = 'is test';
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = strpos($string, $needle);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('strpos', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = strstr($string, $needle);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('strstr', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = substr($string, 0, strlen($needle));
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('substr+strlen', Timer::get());
 }
Exemplo n.º 10
0
 public function run()
 {
     $string = 'some random data';
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         dechex(crc32($string));
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('dechex(crc32())', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         hash('crc32b', $string);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('hash(\'crc32b\')', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         md5($string);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('md5()', Timer::get());
 }
Exemplo n.º 11
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $element_count = 50;
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $object = new \stdClass();
         Timer::stop();
         for ($j = 0; $j <= $element_count; ++$j) {
             Timer::start();
             $object->{$j} = true;
             Timer::stop();
         }
         $bar->update($i);
     }
     unset($object);
     self::addResult('$object', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $array = [];
         Timer::stop();
         for ($j = 0; $j <= $element_count; ++$j) {
             Timer::start();
             $array[$j] = true;
             Timer::stop();
         }
         $bar->update($i);
     }
     self::addResult('$array', Timer::get());
 }
Exemplo n.º 12
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $max = 1000;
     $min = 0;
     $a1 = $a2 = range($min, $max);
     $b1 = $b2 = [];
     $i = $min - 1;
     while (++$i <= $max) {
         $b1[$i] = $b2[$i] = mt_rand($min, $max);
     }
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         foreach ($b1 as $val) {
             unset($a1[$val]);
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('foreach', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $a2 = array_diff_key($a2, array_flip($b2));
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('array_diff_key', Timer::get());
 }
Exemplo n.º 13
0
 public function run()
 {
     $this->prepareTables();
     $repeats = $this->getRepeats();
     $sql = 'SELECT txt FROM test';
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = ODb::rows($sql);
         foreach ($result as $value) {
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('non-generator', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     // Db class initialization
     $pool = new ConnectionPool();
     $conn = new PdoConnection('master');
     $conn->setDsn("mysql:host=localhost;dbname={$this->database};charset=utf8")->setUserName('root')->setPassword('')->setOptions([PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false]);
     $pool->addConnection($conn, true);
     PdoAdapter::setPool($pool);
     Db::setAdapter(PdoAdapter::instance());
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = Db::rows($sql);
         foreach ($result as $value) {
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('generator', Timer::get());
     $this->cleanup();
 }
Exemplo n.º 14
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $myobj1 = new \stdClass();
         $myobj2 = new \stdClass();
         $myobj3 = new \stdClass();
         $myobj4 = new \stdClass();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('New', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $myobj1 = new \stdClass();
         $myobj2 = clone $myobj1;
         $myobj3 = clone $myobj1;
         $myobj4 = clone $myobj1;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Clone', Timer::get());
 }
Exemplo n.º 15
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $dir = self::createDir();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_read_dir($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('readdir()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_dir($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('dir()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_scan_dir($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('scandir()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_diff_scan_dir($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('diff scandir()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_iterator($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('iterator', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         recursive_glob($dir);
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('glob()', Timer::get());
     self::dirCleanup($dir);
 }
Exemplo n.º 16
0
 public function run()
 {
     $this->prepareTables();
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     $value = uniqid();
     $sql = "INSERT INTO test (txt) VALUES ('{$value}')";
     $link = @mysql_connect($this->host, $this->user, $this->password);
     @mysql_select_db($this->database);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         @mysql_query($sql, $link);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('MySQL', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $mysqli = new mysqli($this->host, $this->user, $this->password, $this->database);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $mysqli->query($sql);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('MySQLi', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $link = mysqli_connect($this->host, $this->user, $this->password, $this->database);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         mysqli_query($link, $sql);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('Non-object MySQLi', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $dsn = 'mysql:dbname=' . $this->database . ';' . 'host=' . $this->host . ';' . 'charset=utf8';
     $pdo = new PDO($dsn, $this->user, $this->password);
     $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $pdo->query($sql);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('PDO', Timer::get());
     $this->cleanup();
 }
Exemplo n.º 17
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $bar = new CliProgressBar($repeats);
     Timer::start();
     include 'ThisVsSelf.php';
     Timer::stop();
     $bar->update(1);
     self::addResult('include', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     Timer::start();
     require 'StrtrVsStrReplace.php';
     Timer::stop();
     $bar->update(1);
     self::addResult('require', Timer::get());
 }
Exemplo n.º 18
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $string = uniqid();
     $hashes = hash_algos();
     foreach ($hashes as $hash_name) {
         $bar = new CliProgressBar($repeats);
         for ($i = 1; $i <= $repeats; ++$i) {
             Timer::start();
             hash($hash_name, $string);
             Timer::stop();
             $bar->update($i);
         }
         $this->addResult($hash_name, Timer::get());
         Timer::reset();
     }
 }
Exemplo n.º 19
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $class = '\\Veles\\Config';
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $isFallback = self::ZendisFallbackAutoloader();
         if (false !== strpos($class, self::NS_SEPARATOR)) {
             if (self::ZendloadClass($class, self::LOAD_NS)) {
                 //return $class;
             } elseif ($isFallback) {
                 self::ZendloadClass($class, self::ACT_AS_FALLBACK);
             }
             //return false;
         }
         if (false !== strpos($class, self::PREFIX_SEPARATOR)) {
             if (self::ZendloadClass($class, self::LOAD_PREFIX)) {
                 //return $class;
             } elseif ($isFallback) {
                 self::ZendloadClass($class, self::ACT_AS_FALLBACK);
             }
             //return false;
         }
         if ($isFallback) {
             self::ZendloadClass($class, self::ACT_AS_FALLBACK);
         }
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('Zend', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $file = preg_replace('/\\\\|_(?!.+\\\\)/', DIRECTORY_SEPARATOR, $class) . '.php';
         if (false !== ($full_path = stream_resolve_include_path($file))) {
             /** @noinspection PhpIncludeInspection */
             //require $full_path;
             Timer::stop();
         }
         $bar->update($i);
     }
     self::addResult('Veles', Timer::get());
 }
Exemplo n.º 20
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $date1 = '2011-09-09';
     $date2 = '2011-09-08';
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         if (strtotime($date1) > strtotime($date2)) {
         }
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('strtotime', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         if (strcmp($date1, $date2) > 0) {
         }
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('strcmp', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         if (new \DateTime($date1) > new \DateTime($date2)) {
         }
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('DateTime', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         if ($date1 > $date2) {
         }
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('string', Timer::get());
 }
Exemplo n.º 21
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $uri = '/book/category/344/user/5443';
     $regex = '#^/book/category/(\\d+)/user/(\\d+)$#';
     $named_regex = '#^/book/category/(?P<category_id>\\d+)/user/(?P<user_id>\\d+)$#';
     $named_regex_alt1 = '#^/book/category/(?<category_id>\\d+)/user/(?<user_id>\\d+)$#';
     $named_regex_alt2 = '#^/book/category/(?\'category_id\'\\d+)/user/(?\'user_id\'\\d+)$#';
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         preg_match($regex, $uri, $matches);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('regex', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         preg_match($named_regex, $uri, $matches);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('named regex (?P<name>)', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         preg_match($named_regex_alt1, $uri, $matches);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('named regex (?<name>)', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         preg_match($named_regex_alt2, $uri, $matches);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('named regex (?\'name\')', Timer::get());
 }
Exemplo n.º 22
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     $x = 0;
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $x = $x + 1;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('$x = $x + 1', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $x = 0;
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $x += 1;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('$x += 1', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $x = 0;
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $x++;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('$x++', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     $x = 0;
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         ++$x;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('++$x', Timer::get());
 }
Exemplo n.º 23
0
 public static final function run()
 {
     $repeats = 100000;
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $var = new Test();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('This', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $var = new TestSelf();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('Self', Timer::get());
 }
Exemplo n.º 24
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $a = (int) 5.55;
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('(int)', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $a = intval(5.55);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('intval()', Timer::get());
 }
Exemplo n.º 25
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         include_once 'ThisVsSelf.php';
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('include_once', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         require_once 'ThisVsSelf.php';
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('require_once', Timer::get());
 }
Exemplo n.º 26
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         genStrSuffle();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('genStr', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         genStrArr();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('genStrOpt', Timer::get());
 }
Exemplo n.º 27
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         genStrShuffle();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('genStr', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         genStrArr();
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('genStrOpt', Timer::get());
 }
Exemplo n.º 28
0
 public static final function run()
 {
     $repeats = self::getRepeats();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         rand();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('rand', Timer::get());
     $bar = new CliProgressBar($repeats);
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         mt_rand();
         Timer::stop();
         $bar->update($i);
     }
     self::addResult('mt_rand', Timer::get());
 }
Exemplo n.º 29
0
 public function run()
 {
     $repeats = $this->getRepeats();
     $array = create3DAssocArray(3, 3);
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         json_encode($array);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('json_encode()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         serialize($array);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('serialize()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         var_export($array, true);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('var_export()', Timer::get());
     Timer::reset();
     $bar = new CliProgressBar($repeats);
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         print_r($array, true);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('print_r()', Timer::get());
 }
Exemplo n.º 30
0
 public function run()
 {
     $array = [['ID' => '2'], ['ID' => '3']];
     $repeats = $this->getRepeats();
     $bar = new CliProgressBar($repeats);
     $result = [];
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         $result = array_map(function ($element) {
             return $element['ID'];
         }, $array);
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('array_map', Timer::get());
     $bar = new CliProgressBar($repeats);
     $result = [];
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         foreach ($array as $element) {
             $result[] = $element['ID'];
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('foreach', Timer::get());
     $bar = new CliProgressBar($repeats);
     $result = [];
     Timer::reset();
     for ($i = 1; $i <= $repeats; ++$i) {
         Timer::start();
         foreach ($array as $element) {
             array_push($result, $element['ID']);
         }
         Timer::stop();
         $bar->update($i);
     }
     $this->addResult('array_push', Timer::get());
 }