Author: Peter Fendrich
Date: 11:06:27 01/26/00
Go up one level in this thread
On January 25, 2000 at 23:36:28, Robert Hyatt wrote: >On January 25, 2000 at 18:56:37, Peter Fendrich wrote: > >>I tried to use the clock() function (in NT4) and it didn't behave as I expected >>it to. >>It is said to "Return elapsed CPU time for current process". >>I hoped to be able to run performance tests with my chess program in the >>background while doing other things in the foreground and yet get the same >>results. >>The clock() is definitely affected by other processes so I get very varied >>results depending on what I'm doing in the foreground. >> >>How come? >> >>//Peter > > >There are a dozen answers. > >1. you are context-switching from foreground to background processes. Each >context switch blows out cache. And eats cycles doing so. > >2. Pages are cached in memory when a program executes. It is possible that >your foreground process is using enough memory to affect the background process, >from something like causing it to be paged out, to something like using part of >the free memory pages for buffers/page caches, which means the background >process can't use as many for its purposes. > >It is hard enough to get the same timing result over and over running a >_single_ program, because of a well-known memory to cache aliasing problem >causing unpredictable cache hits on different runs of the same program. If >you add even more variability by running something at the same time, about the >best use of the CPU time is to seed a random number generator. :) This was the behaviour I actually expected. Some random variance surrounding the "real" value. In that case it would be easy to compute how many times I had to do each task in order to get reliable mean values. Instead the clock() time increased heavily when other processes run. I think Amir is right: Ms Visual C++ clock() is returning elapsed time in general and not what ANSI-standard and even Microsofts own documentation says. //Peter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.