Is there a general algorithm that address playback speed of a log file having the following properties. It would be nice to not have to read the whole log file as well, if possible.
- Every line contains a timestamp
- Sampling rate is unknown
The playback would then be able to be played at any speed 2x for example.
thought of a few different ways but thought there might be a generalized algorithm out there.
- read the first timestamp and use that to decide if the next line should be run yet, scheduler-esce.
- read all lines assigning a schedule into memory, then each line will fire at correct time. Again you have to read the first line to get a reference point.
thanks
If the lines in the log file are in chronological order, then it’s pretty easy.
So if you want to run at 2x:
That’s the single-threaded way to do it. I would suggest, though, using two threads: one to read the log and queue commands, and another to read the queue and execute commands.