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
Determining script execution time
-
klownboy
- Posts: 4462
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Determining script execution time
I'm just using now() and datediff() when necessary.
One of my scripts helped you out? Please donate via Paypal
-
klownboy
- Posts: 4462
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440
Re: Determining script execution time
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. 
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Determining script execution time
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Determining script execution time
I tend to use: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.
Code: Select all
$start = now('msecs');
Sub '_testScript';
$duration = now('msecs') - $start;-
klownboy
- Posts: 4462
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440
Re: Determining script execution time
Thanks guys, it looks like using now("msecs") is the best bet for me - testing the execution time of small sections of scripts.
XYplorer Beta Club