Author: David Rasmussen
Date: 02:04:30 02/10/02
Go up one level in this thread
On February 10, 2002 at 04:55:19, David Dory wrote: >>David Rasmussen wrote: >>I don't know what Windows you are talking about (and this is also dependant on >>the compiler, actually much more than the OS), but with gcc and MSVC on Windows >>2000, clock() has a pretty high resolution, and is pretty consistent. If I do >>something like the above, I get consistent results. If you're testing the >>difference between to different ways of doing the same thing, and you loop >>enough times, you will get an ok picture of which is faster, and by how much. > >His post showed he was comparing the speed of two functions, using two different >methods of measuring that speed. > >My opinion is that he should compare both functions using ONE measuring method, >rather than using TWO methods. To make the test as valid as possible, all other >variables should be eliminated (in this case, the variable of the second time >measuring method). > >Testing for ONE variable at a time, is the ONLY way to go. > I agree with that. I seem to remember him measuring it with only one method, namely, putting clock() calls before and after. This method is not "precise", but when your loop around the tested function runs enough times, you will eliminate instabilities. If one function is only 1% faster than another, you will just have to run it with a big enough loop to get a consistent difference of ~1%. I am not saying it's perfect, but it is not totally arbitrary on any of the OS'es I've tried. >When you inadvertently add a second variable to the test - well. You can NOW >> >>But of course I use a profiler for complex problems. After all, clock() isn't >>guaranteed by ANSI C to have a resolution higher than 1 second even. > >MSVC 6 states that clock() has a resolution of 1/1000ths of a second. But you >can't believe that, in my opinion, if the OS is Windows. > >Any Windows OS, (and the older 16-bit'ers are certainly worse), can give you >slightly different times for the exact same task, in my experience, with >clumping. The compiler used is irrelevant. > >For instance, say you time your task at 4.327 seconds. Repeating the exact same >task may give you a sampling of: 4.324, 4.327, 4.330, etc. > >What I haven't seen are results like: 4.326, 4.327, 4.328. > >The results are not perfectly the same, nor are they perfectly granular - >they're "CLUMPY" <grin>, for lack of a better word. > >Sorry, I don't have 7, and know nada about it. > You are right that something like this can happen, but it happens on Linux and Solaris as well, to name the two other OS'es that I work regularly with. They are no more precise in this regard than Windows 2000. Windows can _easily_ do precise timing of 1/1000th second, but MSVC's clock() implementation might not do that, I don't know. /David
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.