[computer-go] Precise clock cycles measurements

Chaslot G (MICC) G.Chaslot at MICC.unimaas.nl
Fri Sep 1 04:27:58 PDT 2006


Łukasz, thanks a lot for this code, this is a great way to measure speed!

Mango's stats, for playing the most stupid games:

Nb of cc per game: 105035
Nb of moves per game: 105.497
Nb of games per second: 26062

So around 996 cc per move in average.

By the way:
Nb of cc per sec = 105035 x 26062 = 2.74 G
The computer being a 2.8 Ghz, this makes sense!

If it plays less stupid games, it is slower: with the current settings about 17000 games per second. 

Best,

Guillaume


Ps1: The macro seems to have a very strange problem with fast things. When measuring the speed of rand(), it gave me an absurd result. I put then 30 rand() instead of one and the result was consistent. Maybe a problem with the "-43"? If we imagine that this -43 would only be true in average, this would explain the strange behavior that I observed.

Ps2: The classical rand()on an opteron using linux seems to use only 30cc.



-----Original Message-----
From: computer-go-bounces at computer-go.org [mailto:computer-go-bounces at computer-go.org] On Behalf Of Lukasz Lew
Sent: Thursday, August 31, 2006 3:06 PM
To: computer-go
Subject: [computer-go] Precise clock cycles measurements

IMHO this is a way better than profiler.
To measure clock cycles accurately of function call

play(color, move)

you may use

unsigned long cc_time;
cc_time_of(cc_time, play(color, move));

Use this macro, (works for g++):
[ Can someone port it to other compilers? ]
---

#define get_cc_cnt(tsc)  __asm__ __volatile__("rdtsc" : "=A" (tsc) : : "edx")

#define cc_time_of(t ,instr) \
  do {\
    unsigned int cc_start, cc_stop;\
    get_cc_cnt(cc_start);\
    instr;\
    get_cc_cnt(cc_stop);\
    t = cc_stop - cc_start - 43;\
  } while (0)

---

So what are Your average cc times of playing:
one move?
playout?

Best regards,
Łukasz


More information about the computer-go mailing list