-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tools for local performance testing
- Loading branch information
Showing
5 changed files
with
128 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 8 additions & 14 deletions
22
packages/fleather/example/test_driver/performance_driver.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,19 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_driver/flutter_driver.dart' as driver; | ||
import 'package:integration_test/integration_test_driver.dart'; | ||
|
||
Future<void> main() { | ||
final outputName = Platform.environment['FLEATHER_PERF_TEST_OUTPUT_NAME']!; | ||
return integrationDriver( | ||
responseDataCallback: (data) async { | ||
if (data != null) { | ||
await writeTimeline(data, 'scrolling_timeline', 'scrolling'); | ||
await writeTimeline(data, 'editing_timeline', 'editing'); | ||
final timeline = | ||
driver.Timeline.fromJson(data['timeline'] as Map<String, dynamic>); | ||
final summary = driver.TimelineSummary.summarize(timeline); | ||
await summary.writeTimelineToFile(outputName, | ||
pretty: true, includeSummary: true); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
Future<void> writeTimeline( | ||
Map<String, dynamic> data, String key, String name) async { | ||
if (!data.containsKey(key)) return; | ||
|
||
final timeline = driver.Timeline.fromJson(data[key] as Map<String, dynamic>); | ||
final summary = driver.TimelineSummary.summarize(timeline); | ||
await summary.writeTimelineToFile(name, | ||
destinationDirectory: 'build/performance_timelines', | ||
pretty: true, | ||
includeSummary: true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/fleather/example/test_utils/run_and_analyze_performance_tests.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:integration_test/integration_test_driver.dart'; | ||
|
||
/// Runs and analyzes performance tests. | ||
/// | ||
/// It's an internal tests for developers and maintainers, and is not safe | ||
/// since you might end up losing your changes. | ||
/// Use with care and commit changes in current branch and master before. | ||
void main() { | ||
final branchName = | ||
Process.runSync('git', ['rev-parse', '--abbrev-ref', 'HEAD']) | ||
.stdout | ||
.toString() | ||
.trim(); | ||
|
||
warning('Running tests for $branchName'); | ||
Process.runSync( | ||
'flutter', | ||
[ | ||
'drive', | ||
'-d', | ||
'macos', | ||
'--driver=test_driver/performance_driver.dart', | ||
'--target=integration_test/scrolling_test.dart', | ||
'--profile', | ||
], | ||
environment: {'FLEATHER_PERF_TEST_OUTPUT_NAME': 'target_scrolling'}, | ||
); | ||
Process.runSync( | ||
'flutter', | ||
[ | ||
'drive', | ||
'-d', | ||
'macos', | ||
'--driver=test_driver/performance_driver.dart', | ||
'--target=integration_test/editing_test.dart', | ||
'--profile', | ||
], | ||
environment: {'FLEATHER_PERF_TEST_OUTPUT_NAME': 'target_editing'}, | ||
); | ||
|
||
Process.runSync('git', ['stash', '--include-untracked']); | ||
Process.runSync('git', ['fetch', 'origin/master']); | ||
Process.runSync('git', ['checkout', 'origin/master']); | ||
|
||
warning('Running tests for origin/master'); | ||
Process.runSync( | ||
'flutter', | ||
[ | ||
'drive', | ||
'-d', | ||
'macos', | ||
'--driver=test_driver/performance_driver.dart', | ||
'--target=integration_test/scrolling_test.dart', | ||
'--profile', | ||
], | ||
environment: {'FLEATHER_PERF_TEST_OUTPUT_NAME': 'ref_scrolling'}, | ||
); | ||
Process.runSync( | ||
'flutter', | ||
[ | ||
'drive', | ||
'-d', | ||
'macos', | ||
'--driver=test_driver/performance_driver.dart', | ||
'--target=integration_test/editing_test.dart', | ||
'--profile', | ||
], | ||
environment: {'FLEATHER_PERF_TEST_OUTPUT_NAME': 'ref_editing'}, | ||
); | ||
|
||
warning('Analyzing tests for scrolling'); | ||
print(Process.runSync('dart', [ | ||
'run', | ||
'test_utils/analyze_performance.dart', | ||
'$testOutputsDirectory/ref_scrolling.timeline_summary.json', | ||
'$testOutputsDirectory/target_scrolling.timeline_summary.json', | ||
]).stdout); | ||
|
||
warning('Analyzing tests for editing'); | ||
print(Process.runSync('dart', [ | ||
'run', | ||
'test_utils/analyze_performance.dart', | ||
'$testOutputsDirectory/ref_editing.timeline_summary.json', | ||
'$testOutputsDirectory/target_editing.timeline_summary.json', | ||
]).stdout); | ||
|
||
Process.runSync('git', ['checkout', branchName]); | ||
Process.runSync('git', ['stash', 'apply']); | ||
} | ||
|
||
void warning(String text) => print('\x1B[33m$text\x1B[0m'); |