mirror of https://github.com/google/benchmark.git
Use the sample version of standard deviation (#383)
* remove unnecessary weights * use sample standard deviation * add contributor information * remove redundant code * initialize variable to eliminate compiler warning
This commit is contained in:
parent
93bfabc8b8
commit
f3b3dd99be
1
AUTHORS
1
AUTHORS
|
@ -32,6 +32,7 @@ Oleksandr Sochka <sasha.sochka@gmail.com>
|
|||
Paul Redmond <paul.redmond@gmail.com>
|
||||
Radoslav Yovchev <radoslav.tm@gmail.com>
|
||||
Shuo Chen <chenshuo@chenshuo.com>
|
||||
Yixuan Qiu <yixuanq@gmail.com>
|
||||
Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Dirac Research
|
||||
Zbigniew Skowron <zbychs@gmail.com>
|
||||
|
|
|
@ -50,6 +50,7 @@ Pierre Phaneuf <pphaneuf@google.com>
|
|||
Radoslav Yovchev <radoslav.tm@gmail.com>
|
||||
Ray Glover <ray.glover@uk.ibm.com>
|
||||
Shuo Chen <chenshuo@chenshuo.com>
|
||||
Yixuan Qiu <yixuanq@gmail.com>
|
||||
Yusuke Suzuki <utatane.tea@gmail.com>
|
||||
Tobias Ulvgård <tobias.ulvgard@dirac.se>
|
||||
Zbigniew Skowron <zbychs@gmail.com>
|
||||
|
|
|
@ -194,16 +194,16 @@ std::vector<BenchmarkReporter::Run> ComputeStats(
|
|||
CHECK_EQ(run_iterations, run.iterations);
|
||||
if (run.error_occurred) continue;
|
||||
real_accumulated_time_stat +=
|
||||
Stat1_d(run.real_accumulated_time / run.iterations, run.iterations);
|
||||
Stat1_d(run.real_accumulated_time / run.iterations);
|
||||
cpu_accumulated_time_stat +=
|
||||
Stat1_d(run.cpu_accumulated_time / run.iterations, run.iterations);
|
||||
items_per_second_stat += Stat1_d(run.items_per_second, run.iterations);
|
||||
bytes_per_second_stat += Stat1_d(run.bytes_per_second, run.iterations);
|
||||
Stat1_d(run.cpu_accumulated_time / run.iterations);
|
||||
items_per_second_stat += Stat1_d(run.items_per_second);
|
||||
bytes_per_second_stat += Stat1_d(run.bytes_per_second);
|
||||
// user counters
|
||||
for(auto const& cnt : run.counters) {
|
||||
auto it = counter_stats.find(cnt.first);
|
||||
CHECK_NE(it, counter_stats.end());
|
||||
it->second.s += Stat1_d(cnt.second, run.iterations);
|
||||
it->second.s += Stat1_d(cnt.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
src/stat.h
16
src/stat.h
|
@ -119,18 +119,22 @@ class Stat1 {
|
|||
if (numsamples_ == 0) return VType();
|
||||
VType mean = sum_ * (1.0 / numsamples_);
|
||||
if (stddev) {
|
||||
VType avg_squares = sum_squares_ * (1.0 / numsamples_);
|
||||
*stddev = Sqrt(avg_squares - Sqr(mean));
|
||||
// Sample standard deviation is undefined for n = 1
|
||||
if (numsamples_ == 1) {
|
||||
*stddev = VType();
|
||||
} else {
|
||||
VType avg_squares = sum_squares_ * (1.0 / numsamples_);
|
||||
*stddev = Sqrt(numsamples_ / (numsamples_ - 1.0) * (avg_squares - Sqr(mean)));
|
||||
}
|
||||
}
|
||||
return mean;
|
||||
}
|
||||
|
||||
// Return the standard deviation of the sample set
|
||||
VType StdDev() const {
|
||||
if (numsamples_ == 0) return VType();
|
||||
VType mean = Mean();
|
||||
VType avg_squares = sum_squares_ * (1.0 / numsamples_);
|
||||
return Sqrt(avg_squares - Sqr(mean));
|
||||
VType stddev = VType();
|
||||
Mean(&stddev);
|
||||
return stddev;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue