I got the following email the other day from a reader:
I cam across your post on pc time and thought you may have a quick answer. Thanks in advance.
I have a program that is a reader that reads a log and sends a message to a second program that is the counter that counts the number of events it gets in a five minutes.
Each entry in the log has a time stamp and is sequential. The log file reader reads the log and waits until it has hit the time in the time stamp (hour, minute and second) and then sends that event to the listner at that time. So to process a log for one day this set takes one day.
I was wondering if there was some way that I could speed up the clock so I dont have to change the logic of either of the programs but have the task completed in say 4 hours (by spedding up the clock by 6 times).
That's a fascinating idea, actually - is there a way of making time go faster?
Whenever someone asks a question like this one, it's time to fall back on the tricks of the master. Whenever he gets a question like this, Raymond always turns around and asks a question like "What if <x> could happen?" (or "What if two applications tried to do <y>?").
So let's ask the question: "What if there was a way of speeding up the system clock so you don't have to wait so long?"
What would that do to system timers? If the entire system time is running faster, then they would also run faster. Would there be a consequence if something that's supposed to happen every 5 minutes all of a sudden started happening every 5 seconds?
How about timeouts? In other words, if I read some data from the disk and wait (with a timeout) for the disk read to complete, will that timeout run faster? What happens the read timeout is 3 seconds and the disk normally takes 2 seconds for an I/O to complete?
Monitor refresh frequency? If your app is synchronized to the monitor refresh wait, and the application all of a sudden starts running twice as fast, what would be the results?
If you're trying to make the system run faster than in real-time, it seems like all these would also speed up (otherwise you couldn't get the log playback operations to be faster, since these all run off the same timer).
This is the crux of the problem - if you want your sleeps to go faster, then all the system events also need to be faster. Unfortunately, there's all this physical hardware attached to the computer, and that physical hardware takes time to complete operations. If you also have timeouts associated with those hardware operations, then you may introduce real problems.
So the simple answer to the question is: "Not usually". It might be possible to do something in a VM environment, and there are some utilities on the web that claim to be able to do this, but I wouldn't recommend them.
Why can't you change the program that plays back the log to simply not wait as long?