Skip to content

Commit

Permalink
test measuring timeline event widget build count
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz committed Jun 2, 2024
1 parent cad7553 commit 7fab238
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
4 changes: 4 additions & 0 deletions commet/lib/ui/molecules/timeline_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class TimelineEventView extends StatefulWidget {
final bool canDeleteEvent;
final Function(Emoticon emote)? onReactionTapped;

static int timelineEventBuildsCount = 0;

@override
State<TimelineEventView> createState() => _TimelineEventState();
}
Expand Down Expand Up @@ -212,6 +214,8 @@ class _TimelineEventState extends State<TimelineEventView> {

@override
Widget build(BuildContext context) {
TimelineEventView.timelineEventBuildsCount += 1;

return eventToWidget(widget.event) ?? Container();
}

Expand Down
31 changes: 6 additions & 25 deletions commet/test_driver/benchmark_driver.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: depend_on_referenced_packages

import 'package:commet/ui/molecules/timeline_event.dart';
import 'package:flutter_driver/flutter_driver.dart';
import 'dart:convert' show JsonEncoder;

Expand All @@ -21,6 +22,11 @@ Future<void> main() {
final summary = TimelineSummary.summarize(timeline);

result.addAll([
{
"name": "Timeline Widget Build Count",
"value": TimelineEventView.timelineEventBuildsCount,
"unit": "Builds"
},
{
"name": "$key - Average Build Time",
"value": summary.computeAverageFrameBuildTimeMillis(),
Expand Down Expand Up @@ -67,31 +73,6 @@ Future<void> main() {
"value": summary.computePercentileFrameRasterizerTimeMillis(50),
"unit": "ms"
},
{
"name": "$key - Frames missed build budget",
"value": summary.computeMissedFrameBuildBudgetCount(),
"unit": "Frames"
},
{
"name": "$key - Frame Count",
"value": summary.countFrames(),
"unit": "Frames"
},
{
"name": "$key - Raster Count",
"value": summary.countRasterizations(),
"unit": "Rasterizations"
},
{
"name": "$key - New generation garbage collections",
"value": summary.newGenerationGarbageCollections(),
"unit": "Collections"
},
{
"name": "$key - Old generation garbage collections",
"value": summary.oldGenerationGarbageCollections(),
"unit": "Collections"
},
]);
}

Expand Down

0 comments on commit 7fab238

Please sign in to comment.