Skip to content

inso/php-benchmark

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Usage

Simple benchmark example, between the date() function and new DateTime::format() :

<?php

require 'Benchmark.php';

$bench = new Benchmark;

$result = $bench
    ->setIterations(10000)
    ->setWarmUpIterations(1000)
    ->addTarget('function', function() {
        return date('Y-m-d');
    })
    ->addTarget('object', function() {
        $date = new DateTime;
        return $date->format('Y-m-d');
    })
    ->warmUp()
    ->execute()
    ->getResults()
;

/*
 * var_dump($result) :
 *
 * array(2) {
 *   'function' =>
 *   array(2) {
 *     'time' =>
 *     double(0.05121898651123)
 *     'percent' =>
 *     int(100)
 *   }
 *   'object' =>
 *   array(2) {
 *     'time' =>
 *     double(0.074388027191162)
 *     'percent' =>
 *     int(145)
 *   }
 * }
 */

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%