Bug in performance test.
yiyuanliu opened this issue · 1 comments
yiyuanliu commented
During performance test, I got some strange results. I noticed that in class PerformanceTest
, it create a tmp buffer and copy data into tmp buffer before run sort. But sort function runs directly on the origin buffer instead of tmp buffer. This causes the remaining tests will be performed on ordered data。
// speed.cc class PerformanceTest
template <typename SORT_FUNCTION>
uint64_t run(SORT_FUNCTION sort) {
uint64_t time = 0;
int k = iterations;
while (k--) {
memcpy(tmp, input.pointer(), input.size());
uint64_t t1, t2;
#ifdef USE_RDTSC
RDTSC_START(t1);
#else
t1 = get_time();
#endif
// !!! should sort tmp buffer, not origin buffer !!!
sort(input.pointer(), 0, input.count() - 1);
#ifdef USE_RDTSC
RDTSC_START(t2);
#else
t2 = get_time();
#endif
const uint64_t dt = t2 - t1;
if (time == 0) {
time = dt;
} else if (dt < time) {
time = dt;
}
}
return time;
}
bbqz007 commented
even thought
if (time == 0) {
time = dt;
} else if (dt < time) {
time = dt;
}
it use the max dt
not the average time.