Skip to content

Commit

Permalink
use the best of four results for flutter analyze --benchmark (flutter…
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew authored Aug 1, 2018
1 parent d2ab29d commit 1393c73
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dev/devicelab/lib/tasks/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

import 'dart:async';
import 'dart:io';
import 'dart:math' as math;

import 'package:path/path.dart' as path;

import '../framework/framework.dart';
import '../framework/utils.dart';

/// Run each benchmark this many times and compute average.
const int _kRunsPerBenchmark = 3;
const int _kRunsPerBenchmark = 4;

/// Runs a benchmark once and reports the result as a lower-is-better numeric
/// value.
Expand Down Expand Up @@ -90,13 +91,13 @@ class _MegaGalleryBenchmark {

/// Runs a [benchmark] several times and reports the average result.
Future<double> _run(_Benchmark benchmark) async {
double total = 0.0;
double best;
for (int i = 0; i < _kRunsPerBenchmark; i++) {
// Delete cached analysis results.
rmTree(dir('${Platform.environment['HOME']}/.dartServer'));

total += await benchmark();
final double result = await benchmark();
best = math.min(result, best ?? result);
}
final double average = total / _kRunsPerBenchmark;
return average;
return best;
}

0 comments on commit 1393c73

Please sign in to comment.