-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
528 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
on: | ||
merge_group: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
name: benchmark | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
env: | ||
PROJECT_PATH: commet | ||
|
||
jobs: | ||
benchmark: | ||
name: benchmark | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: Setup Flutter | ||
uses: subosito/[email protected] | ||
with: | ||
flutter-version: '3.19.5' | ||
channel: 'stable' | ||
|
||
- name: Setup Dependencies | ||
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install -y ninja-build libgtk-3-dev libolm3 libmpv-dev mpv ffmpeg libmimalloc-dev | ||
- name: Configure Flutter | ||
run: flutter config --enable-linux-desktop | ||
|
||
- name: Code Generation | ||
run: | | ||
cd $PROJECT_PATH | ||
dart run scripts/codegen.dart | ||
- name: Benchmark | ||
run: | | ||
cd $PROJECT_PATH | ||
export DISPLAY=:99 | ||
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 & | ||
ffmpeg -f x11grab -video_size 1920x1080 -framerate 15 -i :99 -vcodec libx264 -preset ultrafast -qp 0 -nostdin -loglevel quiet -pix_fmt yuv444p video.mkv & | ||
flutter drive -d linux --driver=test_driver/benchmark_driver.dart --target=integration_test/benchmark/benchmark.dart --profile | ||
INTEGRATION_TEST_EXIT_CODE=$? | ||
sleep 1 | ||
kill $(pgrep ffmpeg) | ||
exit $INTEGRATION_TEST_EXIT_CODE | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: result.mkv | ||
path: commet/video.mkv | ||
|
||
- name: Store benchmark result - separate results repo | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Benchmark | ||
tool: 'customSmallerIsBetter' | ||
output-file-path: commet/build/customSmallerIsBetter.json | ||
github-token: ${{ secrets.BENCHMARK_ACTION_BOT_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '350%' | ||
comment-on-alert: true | ||
fail-on-alert: false | ||
summary-always: true | ||
gh-repository: 'github.com/commetchat/commet_benchmark_results' |
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,8 @@ | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'benchmarks/timeline_viewer_benchmark.dart' as timeline; | ||
|
||
main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
timeline.main(); | ||
} |
64 changes: 64 additions & 0 deletions
64
commet/integration_test/benchmark/benchmarks/timeline_viewer_benchmark.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,64 @@ | ||
import 'package:commet/diagnostic/benchmark_values.dart'; | ||
import 'package:commet/ui/pages/developer/benchmarks/benchmark_utils.dart'; | ||
import 'package:commet/ui/pages/developer/benchmarks/timeline_viewer_benchmark.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:tiamat/config/style/theme_dark.dart'; | ||
|
||
void main() { | ||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
testWidgets('Timeline Viewer Test', (tester) async { | ||
// Build our app and trigger a frame. | ||
await tester.pumpWidget(MaterialApp( | ||
theme: ThemeDark.theme, | ||
home: const Scaffold( | ||
body: BenchmarkTimelineViewer(), | ||
), | ||
)); | ||
|
||
await tester.pump(const Duration(seconds: 1)); | ||
|
||
final listFinder = find.byType(Scrollable); | ||
final itemFinder = find.text(finalEventMessage); | ||
|
||
var reportKey = 'TimelineViewer Scrolling'; | ||
|
||
await binding.traceAction( | ||
() async { | ||
// Scroll until the item to be found appears. | ||
await tester.scrollUntilVisible( | ||
itemFinder, | ||
50.0, | ||
maxScrolls: 10000, | ||
scrollable: listFinder, | ||
); | ||
}, | ||
reportKey: reportKey, | ||
); | ||
|
||
binding.reportData?[reportKey]["extra_values"] = [ | ||
{ | ||
"name": "$reportKey - Timeline Event Build Count", | ||
"value": BenchmarkValues.numTimelineEventsBuilt, | ||
"unit": "Builds", | ||
}, | ||
{ | ||
"name": "$reportKey - Timeline Event Message Body Build Count", | ||
"value": BenchmarkValues.numTimelineMessageBodyBuilt, | ||
"unit": "Builds", | ||
}, | ||
{ | ||
"name": "$reportKey - Timeline Event Message Reply Body Build Count", | ||
"value": BenchmarkValues.numTimelineReplyBodyBuilt, | ||
"unit": "Builds", | ||
}, | ||
{ | ||
"name": "$reportKey - Timeline Event Message Url Preview Build Count", | ||
"value": BenchmarkValues.numTimelineUrlPreviewBuilt, | ||
"unit": "Builds", | ||
} | ||
]; | ||
}); | ||
} |
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
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,6 @@ | ||
class BenchmarkValues { | ||
static int numTimelineEventsBuilt = 0; | ||
static int numTimelineMessageBodyBuilt = 0; | ||
static int numTimelineReplyBodyBuilt = 0; | ||
static int numTimelineUrlPreviewBuilt = 0; | ||
} |
51 changes: 51 additions & 0 deletions
51
commet/lib/diagnostic/mocks/matrix_client_component_mocks.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,51 @@ | ||
import 'package:commet/client/components/url_preview/url_preview_component.dart'; | ||
import 'package:commet/client/matrix/matrix_client.dart'; | ||
import 'package:commet/client/room.dart'; | ||
import 'package:commet/client/timeline.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
extension MatrixClientComponentReplacement on MatrixClient { | ||
void mockComponents() { | ||
componentsInternal.removeWhere((element) => element is UrlPreviewComponent); | ||
componentsInternal.add(MockMatrixUrlPreviewComponent(this)); | ||
} | ||
} | ||
|
||
class MockMatrixUrlPreviewComponent | ||
implements UrlPreviewComponent<MatrixClient> { | ||
@override | ||
MatrixClient client; | ||
|
||
MockMatrixUrlPreviewComponent(this.client); | ||
|
||
var imageIndex = 0; | ||
|
||
@override | ||
Future<UrlPreviewData?> getPreview(Room room, TimelineEvent event) async { | ||
await Future.delayed(const Duration(seconds: 1)); | ||
|
||
var image = [ | ||
"assets/images/app_icon/app_icon_filled.png", | ||
"assets/images/app_icon/app_icon_rounded.png", | ||
"assets/images/app_icon/app_icon_transparent_cropped.png", | ||
"assets/images/app_icon/app_icon_transparent.png" | ||
][imageIndex % 4]; | ||
|
||
imageIndex += 1; | ||
|
||
return UrlPreviewData(Uri.parse("https://example.com"), | ||
siteName: "Example", | ||
description: "Example description", | ||
image: AssetImage(image)); | ||
} | ||
|
||
@override | ||
bool shouldGetPreviewData(Room room, TimelineEvent event) { | ||
return true; | ||
} | ||
|
||
@override | ||
UrlPreviewData? getCachedPreview(Room room, TimelineEvent event) { | ||
return null; | ||
} | ||
} |
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
Oops, something went wrong.