Timing and logging

Hi there,

We are using Panda3d to do science. :slight_smile: I am looking at how to get accurate as possible timing into a log file. I see there is something called TrueClock. How does this compare to datetime.now? Relative times are what are important here, I don’t care what is considered time zero (as long as I know what it is, of course). I will want to log enough information that I can replay the game exactly. So, log everything in the scene, positions, movements, etc. Fortunately, these are very simple games, so it doesn’t end up being that much info, relatively speaking. This use-case doesn’t really fit into the notify-levels of the logger, and it appears Panda3d logging doesn’t record timestamps, so I think it makes most sense to open my own file, but could be wrong about that. Looking for any information about timing and logging to file that I should know about, think about, etc. Does the Panda3d logging module do anything special with buffering? Can I assume the system default for buffering will be the most optimized?

thanks,
Maria

TrueClock contains two clocks: long time and short time. get_long_time provides the most accurate time we have for long periods of time, and will not drift substantially over long periods of time, and get_short_time gives a very precise clock for short periods of time, but may drift over the long haul.

On Windows, the long time is supplied by GetTickCount() and the short time is provided by QueryPerformanceCounter if available.

These are the clocks used by PStats, for example, so if you want to get accurate timing information for something you might consider just creating PStats collectors.

You can configure Panda’s Notify to record timestamps by setting “notify-timestamp true” in Config.prc. I don’t really know what you mean with “buffering”, or if Panda does anything special with that.

As for recording and replaying user activity: this is precisely what the Recorder subsystem is meant to do. When wanting to record a user session, you can set this in Config.prc:

record-session session.bam

Or by creating a RecorderController and calling beginRecord(“session.bam”).

This will record all mouse and keyboard input to the session.bam file, which can be replayed using:

playback-session session.bam

Or by creating a RecorderController and calling beginPlayback(“session.bam”).

For recording other kinds of data, RecorderBase can be subclassed, although this requires writing C++ code, and I can understand if that is a deal-breaker.

Thanks so much, this is very helpful. I’m still unclear as to whether either of the timing mechanisms used by Panda3d would be more accurate than the python call datetime.now(). What is considered short vs long times? Are we talking losing ms over seconds, minutes, hours? I’ll do some measurements, I’m just curious about scale and all possible options at this point. Does using the recorder subsystem affect play/timing? One of the unfortunate parts of measuring and recording timing, is of course, that you are likely to affect the timing of what you are measuring by measuring and recording, so I’m exploring all of my options now, and then will start testing…

cheers,
Maria