How to measure the speed of a script
Posted: 03 Sep 2022 11:19
I had two script solution for a problem and I wanted to decide what is the fastest. I added these rows to the beginning and the ending of the script.
As you can see, I wanted the result in ms. But in the statusbar only 0 or 1000 appeared. I figured out that maybe the now() function didn't give back the whole time, so I changed the first row to
I started to get sensible numbers after that, but once I got a negative one, -49
Then I measured the second script and all numbers became under zero.
Maybe i invented a time travelling script, which goes back in time, and finishes even before started.
Does anybody have an idea why this is happening? Could it be a bug, or did I use incorrect format?
Edit: I tried to change the datediff to It seems ok.
I tried to use this one: but it gave me incorrect numbers again which is actually because the always gives back milliseconds between 900 and 999. Never lower, I tried it in the address bar.
Now I am super confused.
Edit2: maybe the milllisecond fomat is not the ms but this:
Code: Select all
$start = now();
.
.
.
status datediff($start,,"ms")$start_date = now("yyyy-mm-dd hh:nn:ss.fffffff"), copied from the now() section of the help file.I started to get sensible numbers after that, but once I got a negative one, -49
Then I measured the second script and all numbers became under zero.
Maybe i invented a time travelling script, which goes back in time, and finishes even before started.
Does anybody have an idea why this is happening? Could it be a bug, or did I use incorrect format?
Edit: I tried to change the datediff to
Code: Select all
status datediff($start_date,now("yyyy-mm-dd hh:nn:ss.fffffff"),"ms");I tried to use this one:
Code: Select all
status datediff($start_date,now("yyyy-mm-dd hh:nn:ss.ms"),"ms");Code: Select all
now("yyyy-mm-dd hh:nn:ss.ms")Now I am super confused.
Edit2: maybe the milllisecond fomat is not the ms but this:
now("yyyy-mm-dd hh:nn:ss.fff"). And ms can be used only as an interval, so maybe the solution is something like this:
Code: Select all
$start_date = now("yyyy-mm-dd hh:nn:ss.fff");
.
status datediff($start_date,now("yyyy-mm-dd hh:nn:ss.fff"),"ms");