SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2002
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I check the "speed"of my code?

    Is there a way of monitoring the speed of my code. so that I can see the effects of various changes?

    -berzerko

  2. #2
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    function startTimer()
    {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $starttime $mtime;

    }

    function 
    endTimer()
    {
            global 
    $starttime;
            
    $mtime microtime ();
            
    $mtime explode (' '$mtime);
            
    $mtime $mtime[1] + $mtime[0];
            
    $endtime $mtime;
            
    $totaltime round( ($endtime $starttime), );
            return 
    $totaltime;

    }

    //------------------------

    startTimer();

    // your code

    echo "Script execution time".endTimer();

    ?>
    Not tested yet, though.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the apache ab command.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •