Bug 826439 - use floats instead of doubles for exponential histogram statistic calculations; r=vdjeric

This commit is contained in:
Nathan Froyd 2013-01-03 16:21:44 -05:00
parent 4da7f9b90e
commit 96c005f6f9
2 changed files with 6 additions and 3 deletions

View File

@ -746,7 +746,7 @@ void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value,
size_t index) { size_t index) {
Accumulate(value, count, index); Accumulate(value, count, index);
DCHECK_GE(value, 0); DCHECK_GE(value, 0);
double value_log = log(static_cast<double>(value) + 1); float value_log = logf(static_cast<float>(value) + 1.0f);
log_sum_ += count * value_log; log_sum_ += count * value_log;
log_sum_squares_ += count * value_log * value_log; log_sum_squares_ += count * value_log * value_log;
} }

View File

@ -30,8 +30,11 @@ function test_histogram(histogram_type, name, min, max, bucket_count) {
// verify properties // verify properties
do_check_eq(sum, s.sum); do_check_eq(sum, s.sum);
if (histogram_type == Telemetry.HISTOGRAM_EXPONENTIAL) { if (histogram_type == Telemetry.HISTOGRAM_EXPONENTIAL) {
do_check_eq(log_sum, s.log_sum); // We do the log with float precision in C++ and double precision in
do_check_eq(log_sum_squares, s.log_sum_squares); // JS, so there's bound to be tiny discrepancies. Just check the
// integer part.
do_check_eq(Math.floor(log_sum), Math.floor(s.log_sum));
do_check_eq(Math.floor(log_sum_squares), Math.floor(s.log_sum_squares));
do_check_false("sum_squares_lo" in s); do_check_false("sum_squares_lo" in s);
do_check_false("sum_squares_hi" in s); do_check_false("sum_squares_hi" in s);
} else { } else {