Login   Register  
PHP Classes
elePHPant
Icontem

File: example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Marek Szewczyk  >  Stoper  >  example2.php  >  Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: example no 2
Class: Stoper
Measure the time that a script takes to execute
Author: By
Last change: some small modifications due to changes in main class
Date: 2005-03-14 06:01
Size: 776 bytes
 

Contents

Class file image Download
<?php
include_once('class.stoper.php');
$s = new Stoper();

echo 
'starting...<br>';
$s->Start();

// something not important
for ($i 0$i 1000000$i++) {
    
$digit  rand(0100);
}
// end of "not important"

$s->MidTimeStart();
for (
$i 0$i 1000000$i++) {
    
$letter chr(rand(97122));
    
$digit  ord($letter);
}
echo 
$s->showResult('Million "for" loop: ').'<br>';

// again: not important array creation
$arr = array(1216546515515651654654684651684554868);
// end of "not important"


$s->MidTimeStart();
for (
$i 0$i 1000000$i++) {
    
sort($arr);
    
rsort($arr);
}
echo 
$s->showResult('Million array sorting: ').'<br>';

$s->Stop();
echo 
$s->showResult('Full execution time: ').'<br>';
?>