Jump to content

PHP: Execution Time Function

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
18 replies to this topic

#1
Guest_Jordan_*

Guest_Jordan_*
  • Guests
This php file has two functions to determine start time and finish time. Then displays total execution time in seconds.


Usage:

   include execution_time.php


In header of your php script place

   $startTime = slog_time();


In footer of your php script place 

    $totalTime = elog_time($startTime);

     print "Execution Time: $totalTime Seconds";

Attached Files



#2
fgundomiel

fgundomiel

    Newbie

  • Members
  • Pip
  • 2 posts
Thanx for that script

#3
Guest_Jaan_*

Guest_Jaan_*
  • Guests
looking good.. thanks

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Are slog_time() and elog_time() predefined PHP functions, or did you define them yourself in the ZIP file?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#5
o0DarkEvil0o

o0DarkEvil0o

    Newbie

  • Members
  • Pip
  • 2 posts
here is more simple than it?

Quote

in the header of your php:
$bgtime=time();

in the footer of your php:
Print "Execution Time: ".(time()-$bgtime);

Http://boy.us.com/ Multi Utilities Sites
Softwares Downloads, Proxy, Freehosting, ....

#6
DevilsCharm

DevilsCharm

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 884 posts
Simple but useful and powerful. Awesome!

#7
henrich

henrich

    Newbie

  • Members
  • Pip
  • 1 posts
Hello. I find this function very simple and useful! Bravo!

#8
mikelbring

mikelbring

    Programmer

  • Members
  • PipPipPipPip
  • 118 posts
Pretty much the same thing I do, I just don't put it in a function.

#9
adserverexpert

adserverexpert

    Newbie

  • Members
  • PipPip
  • 21 posts
the second one is very simple

#10
hakkatil

hakkatil

    Newbie

  • Members
  • Pip
  • 1 posts
thank you for the script.

#11
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Thanks Jordan, but wouldn't the second one work also? It seems more simpler than the one Jordan posted.

All you have to do is in the header create a variable that will get the current time. Then in the footer get the time it finishes and take away the second one from the first one and print the answer.

I am at school, so how does yours work Jordan?
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!


#12
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I dunno the output of mine, it may have some different format requirements. I posted that in 2006, since then I just use the PEAR::Benchmark libraries.