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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tell how long a script is running for?

    Is there any way to tell how long a script has been running for?

  • #2
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey,

    I'm not sure what you mean. Do you mean the time required for a page to load? If so...

    At the top of the page:

    PHP Code:
    $thing microtime(); 
    at the bottom of the page:

    PHP Code:
    print "This script took " microtime()-$thing " seconds to load."

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That would be the best way...

    If you wanted to calculate the time taken to do a query on a database or something like that, you would just put the same around the particular part of the code.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wanted a notification after a certain amount of time. Do I have to kepp on checking the time? Or is there a way that doesn't put as much of a load on the server?

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Seeing as PHP is run on the server, I wouldnt have thought that you could notify half way through, cos It parses everything before the page is returned.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By default timeout=30s. I want at 29.5 seconds for it to execute a simple function, like:

    function pagetimeout() {
    exit ("Awww, Dang! We ran outta time!");
    }

    by notify, i mean tell the remainder of the script that it is about to TO.


  •  

    Posting Permissions

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