diff --git a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart index 178698c5364..de63b5c11a2 100644 --- a/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart +++ b/dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart @@ -655,7 +655,8 @@ class Timeseries { final double dirtyStandardDeviation = _computeStandardDeviationForPopulation(name, candidateValues); // Any value that's higher than this is considered an outlier. - final double outlierCutOff = dirtyAverage + dirtyStandardDeviation; + // Two standard deviations captures 95% of a normal distribution. + final double outlierCutOff = dirtyAverage + dirtyStandardDeviation * 2; // Candidates with outliers removed. final Iterable cleanValues = candidateValues.where((double value) => value <= outlierCutOff); diff --git a/dev/devicelab/lib/tasks/web_benchmarks.dart b/dev/devicelab/lib/tasks/web_benchmarks.dart index d3defb42fd7..de98f4faedd 100644 --- a/dev/devicelab/lib/tasks/web_benchmarks.dart +++ b/dev/devicelab/lib/tasks/web_benchmarks.dart @@ -114,7 +114,7 @@ Future runWebBenchmark({ required bool useCanvasKit }) async { profileData.completeError(error, stackTrace); return Response.internalServerError(body: '$error'); } - }).add(createStaticHandler( + }).add(createBuildDirectoryHandler( path.join(macrobenchmarksDirectory, 'build', 'web'), )); @@ -188,3 +188,23 @@ Future runWebBenchmark({ required bool useCanvasKit }) async { } }); } + +Handler createBuildDirectoryHandler(String buildDirectoryPath) { + final Handler childHandler = createStaticHandler(buildDirectoryPath); + return (Request request) async { + final Response response = await childHandler(request); + final String? mimeType = response.mimeType; + + // Provide COOP/COEP headers so that the browser loads the page as + // crossOriginIsolated. This will make sure that we get high-resolution + // timers for our benchmark measurements. + if (mimeType == 'text/html' || mimeType == 'text/javascript') { + return response.change(headers: { + 'Cross-Origin-Opener-Policy': 'same-origin', + 'Cross-Origin-Embedder-Policy': 'require-corp', + }); + } else { + return response; + } + }; +}