I have 4 test functions - foo1(), foo2(), foo3() and foo4(). For measurements I use following program:
unsigned __int64 start;
unsigned __int64 stop;
unsigned __int64 sum;
unsigned __int64 orig;
sum = 0;
for (int i = 0; i < 10000; i++)
{
start = __rdtsc();
foo1();
stop = __rdtsc();
sum += (stop - start);
}
orig=sum;
cout << "foo1() \taverage: " << (sum / 10000.0) << ", \tratio: " << ((double)orig / sum) << endl << endl;
sum = 0;
for (int i = 0; i < 10000; i++)
{
start = __rdtsc();
foo2();
stop = __rdtsc();
sum += (stop - start);
}
cout << "foo2() \taverage: " << (sum / 10000.0) << ", \tratio: " << ((double)orig / sum) << endl << endl;
And so on, for foo3() and foo4().
I have this log on console:
foo1() average: 401495, ratio: 1
foo2() average: 24251.2, ratio: 16.5557
foo3() average: 11497.7, ratio: 34.9195
foo4() average: 7439.06, ratio: 53.9713
Does this mean that using foo4 () ~50 times faster (in real time) than foo1 ()?
OR does this mean that foo4() is DEFINITELY better in performance than foo1()?