Nasal timestamp - add elapsed uSec
This commit is contained in:
parent
1d1096d6f7
commit
50d4b37a7d
1 changed files with 9 additions and 1 deletions
|
@ -211,12 +211,15 @@ static void f_timerObj_setSimTime(TimerObj& timer, naContext c, naRef value)
|
|||
}
|
||||
////////////////////
|
||||
/// Timestamp - used to provide millisecond based timing of operations. See SGTimeStamp
|
||||
////
|
||||
/// 0.373404us to perform elapsedUSec from Nasal : Tested i7-4790K, Win64
|
||||
class TimeStampObj : public SGReferenced
|
||||
{
|
||||
public:
|
||||
TimeStampObj(Context *c, FGNasalSys* sys) :
|
||||
_sys(sys)
|
||||
{
|
||||
timestamp.stamp();
|
||||
}
|
||||
|
||||
virtual ~TimeStampObj()
|
||||
|
@ -227,10 +230,14 @@ public:
|
|||
{
|
||||
timestamp.stamp();
|
||||
}
|
||||
int elapsedMSec()
|
||||
double elapsedMSec()
|
||||
{
|
||||
return timestamp.elapsedMSec();
|
||||
}
|
||||
double elapsedUSec()
|
||||
{
|
||||
return timestamp.elapsedUSec();
|
||||
}
|
||||
private:
|
||||
SGTimeStamp timestamp;
|
||||
FGNasalSys* _sys;
|
||||
|
@ -986,6 +993,7 @@ void FGNasalSys::init()
|
|||
NasalTimeStampObj::init("TimeStamp")
|
||||
.method("stamp", &TimeStampObj::stamp)
|
||||
.method("elapsedMSec", &TimeStampObj::elapsedMSec)
|
||||
.method("elapsedUSec", &TimeStampObj::elapsedUSec)
|
||||
;
|
||||
|
||||
flightgear::addons::initAddonClassesForNasal(_globals, _context);
|
||||
|
|
Loading…
Add table
Reference in a new issue