Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Loading times...

  1. #1
    Member fury is an unknown quantity at this point
    Join Date
    Jul 2001
    Posts
    30

    Loading times...

    Hi all,

    I was wondering if there is a script that would show loading times. You know how some webpages/scripts show at the bottom "Loaded in 0.0512 secs" or something like that. How would I go about implementing something like that?

    Thanks

  2. #2
    NLC lucifer is an unknown quantity at this point lucifer's Avatar
    Join Date
    Mar 2001
    Location
    Hades
    Posts
    1,213
    I think they are time to generate page not load it.

    easy

    get system time at start of script.

    do script

    get system time at end

    minus one from the other

    print page generation .....ms

    code depends on the language you use
    };-P

    stuff -->---------------

  3. #3
    NLC Dusty is an unknown quantity at this point Dusty's Avatar
    Join Date
    Oct 2000
    Posts
    2,953
    This would work for Perl and PHP:

    Code:
    $start_time=time();
    
    # script here
    
    $end_time=time();
    print "Generated in ".($end_time-$start_time)." seconds";

  4. #4
    Member fury is an unknown quantity at this point
    Join Date
    Jul 2001
    Posts
    30

    Smile

    thanks very much for your help...

  5. #5
    Registered User findftp is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    Netherlands, Hillegom
    Posts
    68
    Originally posted by Dusty
    This would work for Perl and PHP:

    Code:
    $start_time=time();
    
    # script here
    
    $end_time=time();
    print "Generated in ".($end_time-$start_time)." seconds";
    I've added it too!
    But how about 3 decimals? is it something with printf?
    If so,.. could you please give an example

  6. #6
    FWS Addict atlas has a spectacular aura aboutatlas has a spectacular aura about atlas's Avatar
    Join Date
    Nov 2000
    Posts
    501
    This is for perl:

    Code:
    use Benchmark;
    
    my $startBenchmark = new Benchmark;
    
    ...
    your regular code here
    ...
    
    my $endBenchmark = new Benchmark;
    my $timeDiff = timediff($endBenchmark,$startBenchmark);
    print "Took:" . timestr($timeDiff) . "\n\n";
    There are more options for Benchmark, this is just one way of using it.

    -mk
    atlascgi.com

  7. #7
    Registered User findftp is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    Netherlands, Hillegom
    Posts
    68
    I tested it,.. got info about CPU too!
    I only want time with 3 decimals

    please

  8. #8
    Member fury is an unknown quantity at this point
    Join Date
    Jul 2001
    Posts
    30
    yes I would like to know how to do this too...

    thanks again for all the help..
    - fury

  9. #9
    Registered User findftp is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    Netherlands, Hillegom
    Posts
    68
    anybody ?

  10. #10
    NLC lucifer is an unknown quantity at this point lucifer's Avatar
    Join Date
    Mar 2001
    Location
    Hades
    Posts
    1,213
    fprint sounds like the function your after
    };-P

    stuff -->---------------

  11. #11
    Registered User findftp is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    Netherlands, Hillegom
    Posts
    68
    Originally posted by findftp


    I've added it too!
    But how about 3 decimals? is it something with printf?
    If so,.. could you please give an example
    That's what I already posted before. Could you please give an example?

  12. #12
    striking reality niv has disabled reputation niv's Avatar
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    7,344
    you mean it's giving you like 3.4680723723572345?

    well make an integer $n = $timeseek * 1000 % 1000
    then make a float $f = $n / 1000 + 0.000
    the poster formerly known as needcgispace - NOTHING!
    Obsidian Hosting Networks - Head Admin - Changing the way you play the game.
    URL: http://www.obhost.net/
    IRC: irc.gamesurge.net/obhost

  13. #13
    Member fury is an unknown quantity at this point
    Join Date
    Jul 2001
    Posts
    30
    but is there a builtin way or function to do this?
    - fury

  14. #14
    striking reality niv has disabled reputation niv's Avatar
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    7,344
    i wouldn't know. i'm an idiot.
    the poster formerly known as needcgispace - NOTHING!
    Obsidian Hosting Networks - Head Admin - Changing the way you play the game.
    URL: http://www.obhost.net/
    IRC: irc.gamesurge.net/obhost

  15. #15
    Registered User findftp is an unknown quantity at this point
    Join Date
    Nov 2000
    Location
    Netherlands, Hillegom
    Posts
    68
    This is what I use now. But the script tells me everytime that it took 0.295 seconds.
    What's wrong?

    This is the code


    Code:
    
    use Benchmark;
    my $startBenchmark = new Benchmark;
    
    ##### rest of the script #####
    
    my $endBenchmark = new Benchmark;
    my $timeDiff = timediff($endBenchmark,$startBenchmark);
    $n = ($timeDiff * 1000 % 1000); 
    $f = ($n / 1000 + 0.000);
    $gtime = "<font size=\"-2\">Searched for: $f seconds</font>\n\n";

Closed Thread

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