Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts

    show page load time

    PHP Code:
    <?php

    $starttime 
    time()+microtime();
    function 
    PtimerStop() {
       global 
    $starttime;
       
    $endtime time()+microtime();
       
    $totaltime round($endtime $starttime,4);
       echo 
    'This page took ' $totaltime ' to load.';
    }
    ?>
    Some random page stuff and some other php and some
    database calls and some other stuff that takes forever
    <?php
    PtimerStop
    ();
    ?>
    Pretty standard... But helpful none-the-less.

    -Adam
    Why not thank me?

    http://adamsworld.name

  • #2
    p@p
    p@p is offline
    New Coder
    Join Date
    Apr 2010
    Location
    Indonesia
    Posts
    71
    Thanks
    4
    Thanked 0 Times in 0 Posts
    It's not worked for me?

    It could be worked:

    PHP Code:
    <?php
    // Get Current Time
    $mtime microtime();
    // Split Seconds and Microseconds
    $mtime explode (" "$mtime);
    // Create a single value for start time
    $mtime $mtime[1] + $mtime[0];
    // Write Start Time Into A Variable
    $tstart $mtime;

    // Get current time (Like above) to get end time
    $mtime microtime();
    $mtime explode (" "$mtime);
    $mtime $mtime[1] + $mtime[0];
    // Store end time in a variable
    $tend $mtime;
    // Calculate Difference
    $totaltime = ($tend $tstart);
    // Output the result
    printf ("This page was generated in %f seconds."$totaltime);
    ?>

  • #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts


  •  

    Posting Permissions

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