function testDumpReturnArrayWithMarks()
 {
     $benchmark = new Benchmark();
     $a = $benchmark->add_mark("Start test");
     $b = $benchmark->remove_mark($a);
     $c = $benchmark->dump();
     $this->assertIsA($c, array());
 }
function main()
{
    // Read number of queries to run from URL parameter
    $query_count = 1;
    if (!empty($_GET['queries'])) {
        $query_count = intval($_GET['queries']);
    }
    // Fix the queries limits
    $query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
    $b = new Benchmark();
    $b->bench_updates($query_count);
}
 /**
  * Sigleton
  *
  * @return Benchmark object
  * @author Danillo César de Oliveira Melo
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Benchmark();
     }
     return self::$instance;
 }
Beispiel #4
0
 private static function init()
 {
     self::$initialized = true;
     $root_benchmark = new Benchmark(null, null);
     self::$opened_benchmarks = array();
     self::$opened_benchmarks[] = $root_benchmark;
 }
Beispiel #5
0
 /**
  * singleton construct
  */
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Beispiel #6
0
function show_load_time($layout)
{
    $layout .= '<style type="text/css">
				div.cms_debug{
				background-color: white;
				position: fixed;
				bottom:0;
				-moz-box-shadow:0 -1px 4px #000;
				box-shadow:0 -1px 4px #000;
				-webkit-box-shadow:0 -1px 4px #000;
				padding: 2px 4px 0 4px;
				left:10px;
				opacity:0.3;
			}
			div.cms_debug:hover{
				opacity:1;
			}
		</style>';
    Benchmark::stop('Load Time');
    $layout .= '<div class="cms_debug">';
    foreach (Benchmark::get_totals() as $total) {
        $layout .= $total . '<br>';
    }
    $layout .= '</div>';
}
 public function execute($input_parameters = null)
 {
     try {
         $this->benchmark->start();
         return parent::execute($input_parameters);
     } finally {
         $this->benchmark->end();
     }
 }
Beispiel #8
0
 /**
  * Test timingCurrentToRegistry().
  */
 public function testtimingCurrentToRegistry()
 {
     $this->object->timingStart('test');
     try {
         // Linux
         $black_hole = fopen('/dev/null', 'w');
     } catch (Exception $e) {
         // Windows
         $black_hole = fopen('null', 'w');
     }
     for ($i = 0; $i < 500; $i++) {
         fputs($black_hole, $i);
     }
     $this->object->timingStop('test');
     $current = $this->object->timingCurrentToRegistry('test');
     $this->assertInternalType('float', $current);
     $this->assertTrue($current > 0);
 }
Beispiel #9
0
 public static function getAllMarks()
 {
     $bench = Benchmark::factory();
     $result = array();
     foreach ($bench->getMarks() as $k => $timer) {
         $result[$k] = $bench->getMark($timer->getName());
     }
     return $result;
 }
Beispiel #10
0
 /**
  * Starts the execution. Root path is passed to avoid recalculation.
  *
  */
 public static function execute()
 {
     // Register autoloader:
     spl_autoload_register(array('\\Sifo\\Bootstrap', 'includeFile'));
     // Set paths:
     self::$root = ROOT_PATH;
     self::$application = dirname(__FILE__);
     Benchmark::getInstance()->timingStart();
     self::dispatch(self::$script_controller);
     Benchmark::getInstance()->timingStop();
 }
 /**
  * Database query benchmarks.
  *
  * @return  void
  */
 public function benchmarks()
 {
     $benchmarks = Benchmark::get(TRUE);
     // Moves the first benchmark (total execution time) to the end of the array
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     $table = array();
     $table[] = array('Benchmark', 'Time', 'Memory');
     foreach ($benchmarks as $name => $benchmark) {
         // Clean unique id from system benchmark names
         $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
         $table[] = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
     }
     $this->firephp->fb(array(count($benchmarks) . ' benchmarks took ' . number_format($benchmark['time'], 3) . ' seconds and used up ' . number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB' . ' memory', $table), FirePHP::TABLE);
 }
Beispiel #12
0
 /**
  * Detiene el reloj para efecto del calculo del
  * tiempo de ejecucion de un script
  *
  * @return array $_benchmark
  */
 private static function _stop_clock($name)
 {
     if (isset(self::$_benchmark[$name])) {
         if (PHP_OS == 'Linux') {
             $load = sys_getloadavg();
         } else {
             $load = 0;
         }
         self::$_avgload = $load[0];
         self::$_benchmark[$name]['memory_stop'] = memory_get_usage();
         self::$_benchmark[$name]['final_time'] = microtime();
         list($sm, $ss) = explode(' ', self::$_benchmark[$name]['start_time']);
         list($em, $es) = explode(' ', self::$_benchmark[$name]['final_time']);
         self::$_benchmark[$name]['time_execution'] = number_format($em + $es - ($sm + $ss), 4);
         return self::$_benchmark[$name]['time_execution'];
     }
 }
Beispiel #13
0
 public function add_as_author_of(User_Model $author, ORM $object)
 {
     if ($this->is_possible_to_add_authors_to($object)) {
         Benchmark::start('add_as_author_of');
         try {
             $database = new Database();
             $database->from('workshop_data');
             $database->set(array('object_name' => $object->object_name, 'user_id' => $author->id, 'object_id' => $object->id));
             $database->insert();
         } catch (Kohana_Database_Exception $e) {
             if (strstr($e->getMessage(), 'Duplicate entry')) {
                 throw new Workshop_Duplicate_Author_Exception($author, $object);
             } else {
                 throw $e;
             }
         }
         Benchmark::stop('add_as_author_of');
     } else {
         throw new Workshop_Max_Limit_Exception($object, $this->get_number_of_authors_of($object), 1, $this->config_delegate->max_authors_for($object));
     }
 }
Beispiel #14
0
 static function display()
 {
     $status = array('requested url' => SE::getCurrentUrl(), 'controller' => SE::getController(), 'action' => SE::getAction(), 'params' => 'array(' . join(', ', SE::getParams()) . ')', 'request method' => Request::method());
     self::displayTable($status, 'Dispatcher status');
     $markers = array();
     $old_mark = '';
     foreach (Benchmark::$mark as $mark => $time) {
         $markers[$mark] = Benchmark::time($old_mark, $mark);
         $old_mark = $mark;
     }
     self::displayTable($markers, 'Benchmark');
     if (!empty($_GET)) {
         self::displayTable($_GET, 'GET');
     }
     if (!empty($_POST)) {
         self::displayTable($_POST, 'POST');
     }
     if (!empty($_COOKIE)) {
         self::displayTable($_COOKIE, 'COOKIE');
     }
     self::displayTable($_SERVER, 'SERVER');
 }
Beispiel #15
0
 /**
  * Saves the benchmark results to a database
  * @todo Use the database libraries for this instead of platform-specific DB calls
  *
  * @return void
  */
 public static function save_results()
 {
     // Ignore all of these actions if we have benchmarking disabled
     if (Kohana::config('benchmark.enable') === FALSE) {
         return FALSE;
     }
     // Connect to the benchmark database
     $db = Kohana::config('benchmark.db');
     $link = mysql_connect($db['host'], $db['user'], $db['pass']) or die('Could not connect to benchmark database.');
     mysql_select_db($db['database']) or die('Could not select benchmark database.');
     $table = mysql_real_escape_string($db['table_prefix']) . 'benchmark';
     $benchmark_results = Benchmark::get(TRUE);
     foreach ($benchmark_results as $name => $data) {
         // Don't save the generic system benchmark results
         if (strstr($name, 'system_benchmark_') === FALSE) {
             $query = 'INSERT INTO ' . $table . ' (`name`, `time`, `memory`) VALUES (\'' . mysql_real_escape_string($name) . '\', \'' . mysql_real_escape_string($data['time']) . '\', \'' . mysql_real_escape_string($data['memory']) . '\');';
             // Execute the query
             mysql_query($query, $link);
         }
     }
     // Close the connection to the Benchmar DB
     mysql_close($link);
 }
Beispiel #16
0
 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         case 'csv':
             header('Content-type: text/csv');
             $outstream = fopen("php://output", 'w');
             if (!isset($data[0])) {
                 $data = current($data);
             }
             $firstElm = current($data);
             if (!isset($firstElm[0])) {
                 fputcsv($outstream, array_keys(get_object_vars(current(current($data)))), ',', '"');
             } else {
                 fputcsv($outstream, array_keys(get_object_vars(current($data))), ',', '"');
             }
             function __outputCSV(&$vals, $key, $filehandler)
             {
                 if (!isset($vals[0])) {
                     fputcsv($filehandler, get_object_vars(current($vals)), ',', '"');
                 } else {
                     fputcsv($filehandler, get_object_vars($vals), ',', '"');
                 }
             }
             array_walk($data, '__outputCSV', $outstream);
             fclose($outstream);
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
Beispiel #17
0
 /**
  * Benchmark times and memory usage from the Benchmark library.
  *
  * @return  void
  */
 public function benchmarks()
 {
     if (!($table = $this->table('benchmarks'))) {
         return;
     }
     $table->add_column();
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_row(array('Benchmarks', 'Time', 'Memory'), 'kp-title', 'background-color: #FFE0E0');
     $benchmarks = Benchmark::get(TRUE);
     // Moves the first benchmark (total execution time) to the end of the array
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     text::alternate();
     foreach ($benchmarks as $name => $benchmark) {
         // Clean unique id from system benchmark names
         $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
         $data = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
         $class = text::alternate('', 'kp-altrow');
         if ($name == 'Total Execution') {
             $class = 'kp-totalrow';
         }
         $table->add_row($data, $class);
     }
 }
<?php

$time = array();
$mem = array();
include 'Benchmark.php';
$benchmark = new Benchmark();
if (!empty($_POST)) {
    ob_start();
    foreach ($_POST['code'] as $code) {
        for ($n = 0; $n < $_POST['iterations']; $n++) {
            $benchmark->start();
            eval($code);
            $benchmark->finish();
        }
        $time[] = $benchmark->get_time();
        $mem[] = $benchmark->get_memory();
        $benchmark->flush();
    }
    ob_end_clean();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Benchmark</title>
<style type="text/css">
* { margin:0; padding:0; }
body { font:90% Arial, Helvetica, sans-serif; padding:2em; }
form textarea, form input { font-family:"Courier New", Courier, monospace; }
.block { float:left; }
Beispiel #19
0
if (!is_dir("{$repoPath}/.git")) {
    die("{$repoPath} does not contain .git");
}
// get repo
chdir($repoPath);
// sync trees
foreach ($repoCfg['trees'] as $srcPath => $treeOptions) {
    if (is_string($treeOptions)) {
        $treeOptions = array('path' => $treeOptions);
    }
    $treeOptions = array_merge($exportOptions, $treeOptions, ['dataPath' => false]);
    if (!is_string($srcPath)) {
        $srcPath = $treeOptions['path'];
    } elseif (!$treeOptions['path']) {
        $treeOptions['path'] = $srcPath;
    }
    $srcFileNode = Site::resolvePath($srcPath);
    if (is_a($srcFileNode, 'SiteFile')) {
        $destDir = dirname($treeOptions['path']);
        if ($destDir && !is_dir($destDir)) {
            mkdir($destDir, 0777, true);
        }
        copy($srcFileNode->RealPath, $treeOptions['path']);
        Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}");
    } else {
        $exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions);
        Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult));
    }
}
Benchmark::mark("wrote all changes");
Beispiel #20
0
    } elseif (!$treeOptions['path']) {
        $treeOptions['path'] = $srcPath;
    }
    $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#';
    if (is_file($treeOptions['path'])) {
        $sha1 = sha1_file($treeOptions['path']);
        $existingNode = Site::resolvePath($srcPath);
        if (!$existingNode || $existingNode->SHA1 != $sha1) {
            $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null);
            SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1);
            Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}");
        } else {
            Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}");
        }
    } else {
        $cachedFiles = Emergence_FS::cacheTree($srcPath);
        Benchmark::mark("precached {$srcPath}: " . $cachedFiles);
        $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions);
        Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult));
    }
}
// commit changes
#$repo->git('add --all');
#
#$repo->git(sprintf(
#	'commit -n -m "%s" --author="%s <%s>"'
#	,addslashes($_POST['message'])
#	,$GLOBALS['Session']->Person->FullName
#	,$GLOBALS['Session']->Person->Email
#));
#Benchmark::mark("committed all changes");
Beispiel #21
0
 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
Beispiel #22
0
 /** 
  * Destrcutor
  * 
  * Stops benchmarking
  *
  * @access	public
  *
  * @author Thorsten Schmidt
  * @date 10.08.2009
  * @version 1.0
  * @since 1.0
  */
 public function __destruct()
 {
     Benchmark::stop('GridModule Loading');
 }
Beispiel #23
0
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
// Include benchmark library
require_once '../class/benchmark.php';
// Init class
$benchmark = new Benchmark();
// Two functions to compare
// for example: switch VS ternary operator
function benchmark_compare_one()
{
    $n = rand(0, 9);
    $i = 0;
    switch ($n) {
        case 0:
            $i++;
            break;
        case 1:
            $i++;
            break;
        case 2:
            $i++;
Beispiel #24
0
 /**
  * Rewrite Query to init some debug parameters.
  * @param $query_filters
  * @param $sphinx_indexes
  * @param string $comment
  * @return bool
  */
 public function Query($query_filters, $sphinx_indexes, $comment = "")
 {
     Benchmark::getInstance()->timingStart('search');
     $sphinx_results = $this->sphinx->Query($query_filters, $sphinx_indexes, $comment);
     $sphinx_time = Benchmark::getInstance()->timingCurrentToRegistry('search');
     $debug_sphinx = array("tag" => $comment, "query" => $query_filters, "connection" => $this->sphinx_config['config_file'], "indexes" => $sphinx_indexes, "resultset" => $sphinx_results, "time" => $sphinx_time, "error" => $this->sphinx->_error, "controller" => $this->getCallerClass());
     $debug_sphinx = array_merge($debug_sphinx, $this->query_context);
     $this->query_debug['queries'][$this->query_debug['current_query']] = $debug_sphinx;
     $this->query_debug['time'] = $sphinx_time;
     $this->query_debug['error'] = $this->sphinx->_error;
     $this->query_debug['tag'] = $comment;
     $this->query_debug['total_found'] = $sphinx_results['total_found'];
     $this->query_debug['returned_rows'] = isset($sphinx_results['matches']) ? count($sphinx_results['matches']) : 0;
     Debug::push('searches', $this->query_debug);
     unset($this->query_debug);
     $this->query_debug['current_query'] = 0;
     return $sphinx_results;
 }
Beispiel #25
0
define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH . 'core/Benchmark' . EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
// Load core files
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK . '_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK . '_system_initialization');
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK . '_system_initialization');
// Make the magic happen!
Event::run('system.execute');
// Save benchmark results
Benchmark::save_results();
// Clean up and exit
Event::run('system.shutdown');
Beispiel #26
0
define('KOHANA_CODENAME', 'efímera');
// Test of Kohana is running in Windows
define('KOHANA_IS_WIN', PHP_SHLIB_SUFFIX === 'dll');
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH . 'core/Benchmark' . EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
// Load core files
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK . '_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK . '_system_initialization');
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK . '_system_initialization');
// Make the magic happen!
Event::run('system.execute');
// Clean up and exit
Event::run('system.shutdown');
Beispiel #27
0
<html lang="en">
<head>
\t<title>Test headers</title>
\t<style type="text/css">
\t\tbody { background-color: lemonchiffon; }
\t\ttable { background-color: #fff; }
\t\ttr:nth-child(even) {background: #f1f1f1; }
\t\ttr:nth-child(odd) {background: #FFF; }
\t</style>
</head>
<body>
TAG;
            echo $str;
            echo "<table style='font-size:12px'><tr><th>Count</th><th>Vendor</th><th>Model</th><th>Platform</th><th>Platform Version</th><th>Browser</th><th>Browser Version</th><th>HTTP Headers</th></tr>";
        }
    }
    function footer()
    {
        if ($this->verbose) {
            echo "</body></table>";
            echo "<div style=\"color:#f00;\">Test Complete</div>";
        }
        $dps = $this->count / round($this->time, 4);
        $dps = round($dps, 0);
        echo "<h3>Elapsed time: " . round($this->time, 4) . "s, Total detections: {$this->count}, Detections per second: {$dps}</h3>\n\n";
    }
}
$test = new Benchmark($dataFile);
$test->header();
$test->flyThrough($hd);
$test->footer();
Beispiel #28
0
 /**
  * Inserts global Kohana variables into the generated output and prints it.
  *
  * @param   string  final output that will displayed
  * @return  void
  */
 public static function render($output)
 {
     // Fetch memory usage in MB
     $memory = function_exists('memory_get_usage') ? memory_get_usage() / 1024 / 1024 : 0;
     // Fetch benchmark for page execution time
     $benchmark = Benchmark::get(SYSTEM_BENCHMARK . '_total_execution');
     if (self::config('core.render_stats') === TRUE) {
         // Replace the global template variables
         $output = str_replace(array('{kohana_version}', '{kohana_codename}', '{execution_time}', '{memory_usage}', '{included_files}'), array(KOHANA_VERSION, KOHANA_CODENAME, $benchmark['time'], number_format($memory, 2) . 'MB', count(get_included_files())), $output);
     }
     if ($level = self::config('core.output_compression') and ini_get('output_handler') !== 'ob_gzhandler' and (int) ini_get('zlib.output_compression') === 0) {
         if ($level < 1 or $level > 9) {
             // Normalize the level to be an integer between 1 and 9. This
             // step must be done to prevent gzencode from triggering an error
             $level = max(1, min($level, 9));
         }
         if (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
             $compress = 'gzip';
         } elseif (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE) {
             $compress = 'deflate';
         }
     }
     if (isset($compress) and $level > 0) {
         switch ($compress) {
             case 'gzip':
                 // Compress output using gzip
                 $output = gzencode($output, $level);
                 break;
             case 'deflate':
                 // Compress output using zlib (HTTP deflate)
                 $output = gzdeflate($output, $level);
                 break;
         }
         // This header must be sent with compressed content to prevent
         // browser caches from breaking
         header('Vary: Accept-Encoding');
         // Send the content encoding header
         header('Content-Encoding: ' . $compress);
         // Sending Content-Length in CGI can result in unexpected behavior
         if (stripos(PHP_SAPI, 'cgi') === FALSE) {
             header('Content-Length: ' . strlen($output));
         }
     }
     echo $output;
 }
    // a simple function
    return $x + 1;
}
class clsTest
{
    function method($x)
    {
        // a simple method
        return $x + 1;
    }
    static function static_method($x)
    {
        // a simple method
        return $x + 1;
    }
}
$obj = new clsTest();
$x = 29;
$params = array(&$obj, $x);
$benchmark = new Benchmark('bench function Vs method');
$benchmark->setRunningCount(10000);
$result1 = $benchmark->run('global function', 'f_function_normal', $params);
$result2 = $benchmark->run('object method', 'f_method_normal', $params);
$result3 = $benchmark->run('static object method', 'f_method_static', $params);
$result4 = $benchmark->run('static object method as normal', 'f_method_static_as_normal', $params);
$benchmark->compare($result1, $result2);
$benchmark->compare($result1, $result3);
$benchmark->compare($result1, $result4);
$benchmark->compare($result2, $result3);
$benchmark->compare($result3, $result4);
$benchmark->showResults();
        }
    }
}
// Set default controller and action
define('DEFAULT_CONTROLLER', $route['_default']);
define('DEFAULT_ACTION', 'index');
// Load core files
require SYSPATH . '/core/Model' . EXT;
require SYSPATH . '/core/View' . EXT;
require SYSPATH . '/core/Controller' . EXT;
require SYSPATH . '/helpers/Inflector' . EXT;
require SYSPATH . '/core/Benchmark' . EXT;
require SYSPATH . '/core/Observer' . EXT;
require SYSPATH . '/core/Autoloader' . EXT;
require SYSPATH . '/core/Simplengine' . EXT;
Benchmark::start('total');
// Set view suffix
define('VIEW_SUFFIX', $config['view_suffix']);
// Set base url
define('BASE_URL', $config['base_url']);
if (isset($config[$db_group]['host'])) {
    // Database setup
    define('DB_DSN', $db_driver . ':dbname=' . $config[$db_group]['database'] . ';host=' . $config[$db_group]['host']);
    define('DB_USER', $config[$db_group]['username']);
    define('DB_PASS', $config[$db_group]['password']);
    define('TABLE_PREFIX', $config[$db_group]['prefix']);
    define('USE_PDO', $config[$db_group]['pdo']);
    if (USE_PDO) {
        try {
            $__SE_CONN__ = new PDO(DB_DSN, DB_USER, DB_PASS);
        } catch (PDOException $error) {