From 3cf2585f6fc21e8bb1ebad3cb2a002e35128eeae Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 24 Apr 2025 17:06:02 -0700 Subject: [PATCH] try generic device? --- dev/devicelab/lib/tasks/perf_tests.dart | 46 ++++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index dffa35dd7c8..84f0d46231d 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -8,6 +8,7 @@ import 'dart:ffi' show Abi; import 'dart:io'; import 'dart:math' as math; +import 'package:collection/collection.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as path; import 'package:xml/xml.dart'; @@ -1720,7 +1721,6 @@ class CompileTest { }); /* App Size */ - final String appPath = '$testDirectory/hello_world_swiftui.xcarchive/Products/Applications/hello_world_swiftui.app'; @@ -1729,8 +1729,14 @@ class CompileTest { releaseSizeInBytes = await file('$testDirectory/app.tar.gz').length(); /* Time to First Frame */ - await Process.run('rm', ['./results', '-rf']); + await Process.run(workingDirectory: testDirectory, 'rm', [ + '-rf', + 'benchmarkResults.xcresult' + ]).then((ProcessResult results) { + print(results.stdout); + }); + // Run the benchmarking tests and output the result await Process.run(workingDirectory: testDirectory, 'xcodebuild', [ 'test', '-project', @@ -1738,43 +1744,41 @@ class CompileTest { '-scheme', 'hello_world_swiftui', '-destination', - 'platform=iOS,name=Fluttér 的 iPhone', - '-only-testing:BenchmarkTests/testLaunchPerformance', + 'generic/platform=iOS', + '-only-testing:BenchmarkTests/BenchmarkTests/testTimeToFirstFrame', '-resultBundlePath', - './results/benchmarkResults.xcresult' + 'benchmarkResults.xcresult' ]).then((ProcessResult results) { - if (results.exitCode != 0) { - print(results.stderr); - } + print(results.stdout); }); - await Process.run('xcrun', [ + // read the metrics from the test results + dynamic metricsJson; + await Process.run(workingDirectory: testDirectory, 'xcrun', [ 'xcresulttool', 'get', 'test-results', 'metrics', '--path', - './results/benchmarkResults.xcresult', + 'benchmarkResults.xcresult', '--format', - 'json', - '>', - './results/results.json' + 'json' ]).then((ProcessResult results) { - if (results.exitCode != 0) { - print(results.stderr); - } else { - print("done"); - } + print(results.stdout); + metricsJson = json.decode(results.stdout.toString()); }); - - - // xcrun xcresulttool get test-results metrics --path PerfTestResults2.xcresult --format json > results.json + final dynamic rawMeasurements = metricsJson[0]['testRuns'][0]['metrics'][0]['measurements']; + List measurements = []; + if (rawMeasurements is List) { + measurements = rawMeasurements.map((dynamic e) => double.parse(e.toString())).toList(); + } final Map metrics = {}; metrics.addAll({ 'release_swiftui_compile_millis': watch.elapsedMilliseconds, 'release_swiftui_size_bytes': releaseSizeInBytes, + 'time_to_first_frame': measurements.average }); return TaskResult.success(metrics); });