Author: Heiner Marxen
Date: 06:20:29 02/09/02
Go up one level in this thread
On February 07, 2002 at 18:58:58, martin fierz wrote:
>aloha,
>
>i am just writing a program to generate endgame databases and wanted to check my
>functions, so i did the following:
>
>for a whole database i do (details suppressed)
>
>for(i=0;i<dbsize;i++)
> {
> indextoposition(i,&p);
> positiontoindex(&p, &index);
> if(i!=index)
> printf("\nerror!");
> }
>
>and ran the profiler on this. it says:
>
> Funct. funct.+subfunct. number of calls function
> time % time %
>------------------------------------------------------------------
> 1501.647 37.3 3178.206 78.8 201272 _positiontoindex (index.obj)
> 974.731 24.2 974.731 24.2 1124592 _bitcount (bool.obj)
> 497.789 12.3 497.789 12.3 598576 _LSB (bool.obj)
> 401.534 10.0 401.534 10.0 204056 _indextoposition (index.obj)
> 371.568 9.2 3951.488 98.0 35 _buildsubdb (dbmain.obj)
> 204.039 5.1 204.039 5.1 236520 _MSB (bool.obj)
> 71.608 1.8 71.608 1.8 1 _initdatabases (dbmain.obj)
> 7.125 0.2 7.125 0.2 1 _initbool (bool.obj)
> 0.744 0.0 4030.994 100.0 1 _main (dbmain.obj)
> 0.180 0.0 0.180 0.0 161 _getdatabasesize (dbmain.obj)
> 0.028 0.0 3951.517 98.0 5 _builddb (dbmain.obj)
>
>so, i guessed, positiontoindex is 8 times slower than indextoposition (same
>number of calls, 8x more time needed). that's bad, because both the generator
>and the program themselves will both need a fast positiontoindex function. so i
>decided to test again and did this without profiling, but with a time
>measurement for a certain database:
Disclaimer: I've no experience with the MSVC profiler.
But I have experienced some problems with several UNIX profilers, which
may appear elsewhere, also.
Once I found, that too much code was considered to be part of a function.
If there were "static" functions (the names of which are not exported,
and not visible to the naive profiling software) following immediately
some non-static function, then the time spent in the static function
was added to the non-static before it.
I detected that because I did not believe the absurd results of the profiler,
and did some experiments until I found the explanation described above.
>for(i=0;i<dbsize;i++)
> {
> indextoposition(i,&p);
> positiontoindex(&p, &index);
> if(i!=index)
> printf("\nerror!");
> }
>
>result: 17.5 seconds. then i did this
>
>for(i=0;i<dbsize;i++)
> {
> indextoposition(i,&p);
> //positiontoindex(&p, &index);
> //if(i!=index)
> // printf("\nerror!");
> }
>
>result: 13.2 seconds.
At least you should repeat both kinds of experiment several times,
say at least 10 times, to find out how accurate the timing is.
You may quite well find that times vary by 10% or more from run to run.
Next, you should try to compare apples to apples. E.g. look at the
difference between those bodys:
indextoposition(i,&p);
positiontoindex(&p, &index);
indextoposition(i,&p);
indextoposition(i,&p);
positiontoindex(&p, &index);
indextoposition(i,&p);
positiontoindex(&p, &index);
positiontoindex(&p, &index);
That should give something like a peak speed of both functions.
"peak" because most probably those functions will run completely
out of cache, which may not be the case in your real application.
Cache performance can make a huge difference, I've been bitten by that.
>i don't get it - this means that indextoposition is 3 times slower than
>positiontoindex. that's a factor of **** 24 **** different than what the
>profiler tells me. i can understand that profiling is not easy, and that
>measurements may not be accurate. but a factor 24? any suggestions on what is
>wrong here?
Not really. I'm a bit perplexed, also.
May be you should try your own timing function instead of running code
which is instrumented for a profiler. I.e. in doubt do not trust the profiler,
since it changes the object to measure.
>aloha
> martin
>
>PS i was using visual C++ 6.0 professional.
Cheers,
Heiner
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.