PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Carl Taylor  >  profiler  >  example.php  
File: example.php
Role: ???
Content type: text/plain
Description: Example usage
Class: profiler
Class to perform code profiling.
 

Contents

Class file image Download
<html>
<head>
    <title>Profiler Example</title>
<LINK REL=STYLESHEET TYPE=text/css HREF=/profiler/basestyle.css>
</head>
<body>
<?php
        include_once('./profiler.inc');
        $prof = new Profiler( true ); // Output the profile information but no trace

        print("<h4>Scroll Down to see profiler output</h4>");
        $prof->startTimer( "initialise" );
        initialise_routine();
        $prof->stopTimer( "initialise" );

        $prof->startTimer( "main_loop" );

        while( $record=get_record() ){
            print_record( $record );
        }

        $prof->stopTimer( "main_loop" );

        print("<h4>The following is the profiler output</h4>");
        $prof->printTimers( true );
	print("<br><hr>Please let me know if you have any questions or suggestions for improvements.<a href=mailto:profiler@adepteo.net>profiler@adepteo.net</a><br>\n");


        function initialise_routine()
        {
            $n=10000;
            while( $n-- )
                ;
        }

        function get_record()
        {
            global $prof;
            static $count=10;

            if($count==0){
                return;
            }

            $prof->startTimer( "get_record" );
            for( $i=0; $i<10; $i++ ){
                $rec[$i]="Record $count Field $i";
            }
            $prof->stopTimer( "get_record" );
            $count--;
            return( $rec );
        }

        function print_record( $record )
        {
            global $prof;
            // print header information
            print("Record Header Information<br>\n");
            $prof->startTimer( "main_print_record" );
            // main print processing
            foreach( $record as $key=>$val ){
                print( "$key = $val<br>\n");
            }
            $prof->stopTimer( "main_print_record" );
        }
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products