Page 1 of 1

Determining script execution time

Posted: 07 Jul 2014 13:01
by klownboy
Hi, is there a standard or best method to check the execution time for a script or more importantly a portion of a script. A number of times I've worked out various methods to accomplish the same task but wondered how much more efficient one method is verse another. I've been writing to a file before and after the portion of the script I'm timing. It works, but it's a little cumbersome going to look at the files and the milliseconds between the two. Is it better to build a little routine which uses SC now() along with datediff. I was just curious if any one had a standard method or if it's built in to XY and I'm not aware of it? Thanks
Ken

Re: Determining script execution time

Posted: 07 Jul 2014 13:32
by highend
I'm just using now() and datediff() when necessary.

Re: Determining script execution time

Posted: 07 Jul 2014 14:31
by klownboy
Thanks highend. It looks like that is the simplest way (certainly easier than writing to files). I set a variable before and after the portion of the script I was timing using now("msecs"), and then had a message back pop up to reveal the two times. It's amazing how much faster using 8 lines of XY code is to a one DOS command line with runret. :)

Re: Determining script execution time

Posted: 07 Jul 2014 14:36
by SkyFrontier

Re: Determining script execution time

Posted: 07 Jul 2014 14:45
by TheQwerty
I tend to use:

Code: Select all

$start = now('msecs');
Sub '_testScript';
$duration = now('msecs') - $start;
Mainly because using datediff alone can give you some less than ideal results and if the result is so big that I need the full string description then the value doesn't matter _testScript is too slow.

Re: Determining script execution time

Posted: 07 Jul 2014 20:09
by klownboy
Thanks guys, it looks like using now("msecs") is the best bet for me - testing the execution time of small sections of scripts.