MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I access system time in MatrixX v62.2?

I have written a number of scripts (MathScript) to extract block information from my SystemBuild models.  I have thought that it would be useful to display the elapsed time after the script has executed, however the functions provided in the version that I'm running (MatrixX version 62.2) don't seem to provide what I'm looking for.  The function I am currently trying to use is clock() and its variants;
 
clock() - is no good, as it gives you the elapsed time since the last call.  If I write code that looks like this;
 
clock()
doSomeStuff()
elapsedTime = clock()
 
I can't be guaranteed that there are no calls to clock() within doSomeStuff(), so elapsedTime may not be the time elapsed since I called doSomeStuff().
 
I'm running on a windows xp platform, so clock({cpu}) does the same as clock().
 
Of course, I could use the clock({time}) and clock({date}) variants, convert them to a time in seconds since the start of the day or the month and just use that as a reference, but that just seems kinda wrong.  Although it is unlikely that anyone would be running these scipts at 12:00 at night at the end of the month, I know that somewhere along the way something had to know the system time to figure out the time and the date anyway.
 
Is this conversion performed by clock()?  What function(s) does it use to access the system time? Are they accessible directly from XMath?
 
0 Kudos
Message 1 of 3
(8,468 Views)

You're right in that clock() can't be nested thus it does not gaurantee correct results across a script. That use case was obviously not considered.

I don't see why using clock({time}) is "not right". Yes, you'll have to compute a delta-t to get an accurate elapsed time, but unless you expect durations of more than 24 hrs, it's a pretty simple thing to do.

If you think that you need a bullet-proof mechanism, or you need more accurate resolution on your time, there's always the option of writing you're own LNX that you use to compute the elapsed time as you need it to be done. Maybe use oscmd commands to a perl script (or other script language) that can compute time differences easily would work just as well too. Either way, there's some programming involved.

Bob Pizzi
MATRIXx R&D

0 Kudos
Message 2 of 3
(8,461 Views)
Thanks for the feedback Bob.  I hadn't really considered using the negative result produced across 12:00 as a trigger for just adding another 24 hours to the result.  I can't see myself needing to run a script that runs for more than 24 hours, I just wanted some feedback so that I know how long they're running for.
 
I will attach a version of the mso that I have built in case anyone wants it (had to attach as a txt, as mso is not in the allowed list).
0 Kudos
Message 3 of 3
(8,440 Views)