
"Hurd, Matthew" <hurdm@sig.com> wrote
This is an Intel P43.2 I'm running on now and I'm getting output like:
boost function measurements: median time = 250.698 microseconds direct in-line: median time = 250.691 microseconds
You see here I look at the median time for boost function and direct-inline and see only a 7 ns difference which is probably smaller than I can truly measure I suspect...
I wrote my own test (the most simple one, call function/boost::fn in loop and measuring total time). The numbers I got give me ~18 microseconds overhead per single boost::function call (raw call takes ~404 microseconds). I use Intel C++ 8.0 plugged in VC6 IDE,, release mode, Athlon XP 2200+, W2K. /Pavel ------- test (shortened) ----- #define MAX_FN_LOOP 1e5 static double not_empty() { static double sum; static double i; sum = 0.0; for (i = 0.0; i < MAX_FN_LOOP ; ++i) { sum += i * i; } return sum; } void test1() { DWORD tick1 = GetTickCount(); double x = 0; for (int i = 0; i < 100000; ++i) { x += not_empty(); } DWORD tick2 = GetTickCount(); } void test2() { DWORD tick1 = GetTickCount(); boost::function< double (void)> fn = ¬_empty; double x = 0; for (int i = 0; i < 100000; ++i) { x += fn(); } DWORD tick2 = GetTickCount(); } ---------------------------------- test1() and test2() took each 30-40 seconds. GetTickCount() resolution is at least 10 milliseconds.