2,736
edits
Red Leader (talk | contribs) |
Red Leader (talk | contribs) (→systime(): Doc) |
||
| Line 2,089: | Line 2,089: | ||
}} | }} | ||
=== systime() === | === systime() === | ||
Returns | {{Nasal doc | ||
|syntax = systime(); | |||
|source = {{flightgear file|src/Scripting/NasalSys.cxx|l=770|t=Source}} | |||
|text = Returns the {{wikipedia|Unix time}} (seconds since since 00:00:00 UTC, 1/1/1970) as a floating point number with high resolution. This function is useful for benchmarking purposes (see example 2). | |||
{{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 | |||
|example2 = var t = systime(); # record time | |||
{ | var myFunc = func(){ | ||
var pos = geo.aircraft_position(); # get aircraft position | |||
var info = geodinfo(pos.lat(), pos.lon()); # get info | |||
} | |||
var t2 = systime(); # record new time | |||
print("myFunc() took ", t2 - t, " seconds"); # print result | |||
}}<!-- | |||
=== history() (3.1+) === | === history() (3.1+) === | ||