Unverified Commit a96fb449 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Increase the precision of the performance benchmarks. (#20159)

parent a29c6d9b
......@@ -163,17 +163,15 @@ class TimelineSummary {
double _averageInMillis(Iterable<Duration> durations) {
if (durations.isEmpty)
throw new ArgumentError('durations is empty!');
final int total = durations.fold<int>(0, (int t, Duration duration) => t + duration.inMilliseconds);
final double total = durations.fold<double>(0.0, (double t, Duration duration) => t + duration.inMicroseconds.toDouble() / 1000.0);
return total / durations.length;
}
double _percentileInMillis(Iterable<Duration> durations, double percentile) {
if (durations.isEmpty)
throw new ArgumentError('durations is empty!');
assert(percentile >= 0.0 && percentile <= 100.0);
final List<double> doubles = durations.map<double>((Duration duration) => duration.inMilliseconds.toDouble()).toList();
final List<double> doubles = durations.map<double>((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0).toList();
doubles.sort();
return doubles[((doubles.length - 1) * (percentile / 100)).round()];
......@@ -182,9 +180,8 @@ class TimelineSummary {
double _maxInMillis(Iterable<Duration> durations) {
if (durations.isEmpty)
throw new ArgumentError('durations is empty!');
return durations
.map<double>((Duration duration) => duration.inMilliseconds.toDouble())
.map<double>((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0)
.reduce(math.max);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment