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
Родитель 4da7f9b90e
Коммит 96c005f6f9
2 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -746,7 +746,7 @@ void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value,
size_t index) {
Accumulate(value, count, index);
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_squares_ += count * value_log * value_log;
}

Просмотреть файл

@ -30,8 +30,11 @@ function test_histogram(histogram_type, name, min, max, bucket_count) {
// verify properties
do_check_eq(sum, s.sum);
if (histogram_type == Telemetry.HISTOGRAM_EXPONENTIAL) {
do_check_eq(log_sum, s.log_sum);
do_check_eq(log_sum_squares, s.log_sum_squares);
// We do the log with float precision in C++ and double precision in
// 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_hi" in s);
} else {