Time Management
[Nebula Kernel]
Detailed Description
Nebula provides a single realtime time source to assist in decoupling simulation speed from the frame rate.Nebula has two main time management services. The first is nTimeServer, which provides time management function and must be updated each frame. The second is nProfiler, which is a simple class for measuring time intervals.
nTimeServer
nTimeServer provides a single realtime source to decouple simulation speed from the frame rate. It also offers a 'mini' high-resolution timer class, nProfiler, that can be used by client code for profiling and local time measurement reasons.
Time is started when the time server is created. There are various functions for controlling time.
The current time value can be retrieved with nTimeServer::GetTime() and nTimeServer::GetFrameTime(). The difference being that the value returned by nTimeServer::GetFrameTime() is guaranteed to be the same between two nTimeServer::Trigger() calls, which is usually one frame.
The time server usually updates time based on system timers, but it can be set to a fixed time step with nTimeServer::LockDeltaT(). Setting this causes time to be increased by the value passed to nTimeServer::LockDeltaT() each time nTimeServer::Trigger() is called, rather than the actual time taken between calls. For example:
timeServer->LockDeltaT(0.01);
This would mean that time increases by 0.01 seconds each frame, whatever the frame rate.
nTimeServer::WaitDeltaT() can be used to make Nebula sleep for a set amount of time for each call to nTimeServer::Trigger().
nProfiler
nProfiler objects can be queried by a corresponding environment variable, /sys/var/prof_[name], where [name] is the name given to the constructor. The value returned by the environment variable is updated when the nProfiler is rewound (by calling Rewind()).
Create a new profiler.
nProfiler *p_update; // This creates a timer with an nEnv at /sys/var/prof_my_update p_update = timeServer->NewProfiler("my_update");
Start() and Stop() can be called multiple times, and the total time accumulated will be put into the nEnv once the profiler is rewound, not just the interval between the last Start()/Stop() sequence.
Update the nEnv and reset the profiler.
p_update->Rewind();
Classes | |
| class | nProfiler |
| nProfiler provides an easy way to measure time intervals. More... | |
| class | nTimeServer |
| nTimeServer provides a high resolution time source. More... | |