summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2011-05-09 21:29:02 +0000
committersnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2011-05-09 21:29:02 +0000
commitf9c515d1c3f8ea5ca437291bf2ea17470eaf5316 (patch)
tree2dc204820493a5a14684fcfd32a3d15be07985a8
parent3a172157f6113b748b37a3bc231af8c39c69210f (diff)
downloadsnappy-f9c515d1c3f8ea5ca437291bf2ea17470eaf5316.tar.gz
Fix public issue #39: Pick out the median runs based on CPU time,
not real time. Also, use nth_element instead of sort, since we only need one element. R=csilvers DELTA=5 (3 added, 0 deleted, 2 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=1799 git-svn-id: http://snappy.googlecode.com/svn/trunk@35 03e5f5b5-db94-4691-08a0-1a8bf15f6143
-rw-r--r--snappy-test.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/snappy-test.cc b/snappy-test.cc
index 4c8caaf..2c50388 100644
--- a/snappy-test.cc
+++ b/snappy-test.cc
@@ -168,7 +168,7 @@ struct BenchmarkRun {
struct BenchmarkCompareCPUTime {
bool operator() (const BenchmarkRun& a, const BenchmarkRun& b) const {
- return a.real_time_us < b.real_time_us;
+ return a.cpu_time_us < b.cpu_time_us;
}
};
@@ -204,7 +204,10 @@ void Benchmark::Run() {
benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us;
}
- sort(benchmark_runs, benchmark_runs + kNumRuns, BenchmarkCompareCPUTime());
+ nth_element(benchmark_runs,
+ benchmark_runs + kMedianPos,
+ benchmark_runs + kNumRuns,
+ BenchmarkCompareCPUTime());
int64 real_time_us = benchmark_runs[kMedianPos].real_time_us;
int64 cpu_time_us = benchmark_runs[kMedianPos].cpu_time_us;
int64 bytes_per_second = benchmark_bytes_processed * 1000000 / cpu_time_us;