PHP Classes
elePHPant
Icontem

File: Fogg/Util/Timer/Profiler/Example.php

Recommend this page to a friend!
  Classes of Jacob Fogg  >  PHP Multi Profiler Class  >  Fogg/Util/Timer/Profiler/Example.php  >  Download  
File: Fogg/Util/Timer/Profiler/Example.php
Role: Example script
Content type: text/plain
Description: An example class for the Profiler
Class: PHP Multi Profiler Class
Measure the performance of functions and classes
Author: By
Last change:
Date: 4 years ago
Size: 671 bytes
 

Contents

Class file image Download
<?php
require('Profiler.php');

use
Fogg\Util\Timer\Profiler\Profiler;

//Instantiate a profiler object
echo "Start the profiler.<br>\n";
$profiler = new Profiler();

//Profile a function
$profiler->profileFunction('rand',[0,9999]);

//profile a class instantiation
$profiler->profileClass('mysqli',['localhost', 'my_user', 'my_password', 'world']);

//profile a namespaced class
$profiler->profileClass('Fogg\Util\Timer\Profiler\Profiler',[100]);

//profile a method
$profiler->profileMethod(new mysqli(),'query',['select count(*) from users;']);

//print out the results
echo "<h1>Profile Results as array</h1>";
print_r($profiler->getResults());