PHP Classes

File: benchmark.php

Recommend this page to a friend!
  Classes of James Blond   Simple benchmark   benchmark.php   Download  
File: benchmark.php
Role: Example script
Content type: text/plain
Description: testing script
Class: Simple benchmark
Measure the time a PHP script takes to run
Author: By
Last change:
Date: 15 years ago
Size: 763 bytes
 

Contents

Class file image Download
<?php
require_once "./classes/benchmark.class.php";
$bm = new benchmark();
?>
<h2>Test Inline Tags vs echo</h2>

<p>

<?php $bm->timer_start('echo'); ?>
<?php
for ($i=0; $i<1000; $i++) {
    echo
$i."<br>";
}
?>
<?php $bm
->timer_stop('echo'); ?>

<p>

<?php $bm->timer_start(str); ?>
<?php
$str
= '';
for (
$i=0; $i<1000; $i++) {
   
$str .= $i."<br>";
}
echo
$str;
?>
<?php $bm
->timer_stop(str); ?>

<p>
 <?php $bm->timer_start(inline); ?>
<?php
for ($i=0; $i<1000; $i++) {
?>
123<br>
<?php
}
?>
<?php $bm
->timer_stop(inline); ?>

<p>
<br>

<h2>Result</h2>

echo - <?php echo $bm->timer_result('echo'); ?>

<p>

str - <?php echo $bm->timer_result(str); ?>

<p>

inline - <?php echo $bm->timer_result(inline); ?>