2,736
edits
Red Leader (talk | contribs) (→systime(): Doc) |
Red Leader (talk | contribs) (→systime(): Fix example) |
||
| Line 2,095: | Line 2,095: | ||
{{note|1=High resolution timers under Windows can produce inaccurate or fixed sub-millisecond results.<ref>{{cite web|url=http://forum.flightgear.org/viewtopic.php?f=30&t=29259|title=Nasal: systime() ??!?|author=Necolatis|date=Apr 2nd, 2016}}</ref> This is due to the underlying {{func link|GetSystemTimeAsFileTime()|ext=https://msdn.microsoft.com/en-us/library/windows/desktop/ms724397(v=vs.85).aspx}} API call, which depends on hardware availability of suitable high resolution timers. See also [https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx Acquiring high-resolution time stamps]}} | {{note|1=High resolution timers under Windows can produce inaccurate or fixed sub-millisecond results.<ref>{{cite web|url=http://forum.flightgear.org/viewtopic.php?f=30&t=29259|title=Nasal: systime() ??!?|author=Necolatis|date=Apr 2nd, 2016}}</ref> This is due to the underlying {{func link|GetSystemTimeAsFileTime()|ext=https://msdn.microsoft.com/en-us/library/windows/desktop/ms724397(v=vs.85).aspx}} API call, which depends on hardware availability of suitable high resolution timers. See also [https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx Acquiring high-resolution time stamps]}} | ||
|example1 = print("Unix time: ", systime()); # prints Unix time | |example1 = print("Unix time: ", systime()); # prints Unix time | ||
|example2 = | |example2 = var myFunc = func(){ | ||
for(var i = 0; i <= 10; i += 1){ | |||
var myFunc = func(){ | print("Interation #", i); | ||
var | } | ||
} | } | ||
var t = systime(); # record time | |||
myFunc(); # run function | |||
var t2 = systime(); # record new time | var t2 = systime(); # record new time | ||
print("myFunc() took ", t2 - t, " seconds"); # print result | print("myFunc() took ", t2 - t, " seconds"); # print result | ||