Slide 1

Slide 1 text

Integration Test Ͱ ύϑΥʔϚϯεܭଌ͢Δ 2023/12/08 YOUTRUST x ΏΊΈ Flutter LTձ #4 x.com/kumamo_tone

Slide 2

Slide 2 text

• CA. fl utter #1 ͱ͍͏ΠϕϯτͰɺIntegration TestͰฏۉϑϨʔϜϏϧ υ࣌ؒͳͲΛܭଌ͍ͯ͠Δͱ͍͏࿩Λฉ͍ͨ • ࢼͯ͠ΈͨͷͰͪΐͬͱ۷ΓԼ͛ͯΈ·͢ ࠓճͷ࿩ CA. fl utter #1 ʹࢀՃ͠·ͨ͠ - kumamotone’s blog https://kumamotone.hatenadiary.jp/entry/2023/11/14/202304

Slide 3

Slide 3 text

औΕΔ΋ͷ { "average_frame_build_time_millis": 0.7377550000000005, "90th_percentile_frame_build_time_millis": 1.265, "99th_percentile_frame_build_time_millis": 3.401, "worst_frame_build_time_millis": 5.096, "missed_frame_build_budget_count": 0, "average_frame_rasterizer_time_millis": 1.9002878787878796, "90th_percentile_frame_rasterizer_time_millis": 3.648, "99th_percentile_frame_rasterizer_time_millis": 4.868, "worst_frame_rasterizer_time_millis": 6.207, "missed_frame_rasterizer_budget_count": 0, "frame_count": 200, "frame_rasterizer_count": 198, "new_gen_gc_count": 14, "old_gen_gc_count": 0, "frame_build_times": [ 715, …

Slide 4

Slide 4 text

• ৚݅Λม࣮͑ͯߦ͢Δ͜ͱͰɺͲͷΑ͏ͳ৔߹ʹύϑΥʔϚϯε͕ѱ ͘ͳ͍ͬͯΔ͔ܭଌ͢Δ͜ͱ͕Ͱ͖Δ • ܧଓతʹCIͰఆظతʹճ͢͜ͱʹΑͬͯɺύϑΥʔϚϯε͕ѱ͘ͳͬ ͨλΠϛϯάΛଊ͑Δ͜ͱ͕Ͱ͖Δ ظ଴͍ͯ͠Δ͜ͱ

Slide 5

Slide 5 text

• https://github.com/kumamotone/ fl utter_performance_pro fi ling ϦϙδτϦ

Slide 6

Slide 6 text

• main.dart • ܭଌ͍ͨ͠ΞϓϦ • integration_test/scrolling_test.dart • integration_test • test_driver/perf_driver.dart • driver • ςετΛ࣮ߦͨ͠ࡍʹɺͲ͜ʹܭଌ݁ՌΛग़ྗ͢Δ͔౳Λࢦఆ͢Δ ༻ҙ͢Δ΋ͷ

Slide 7

Slide 7 text

ίϚϯυ fl utter drive \ --driver=test_driver/perf_driver.dart \ --target=integration_test/scrolling_test.dart \ --pro fi le \ --no-dds

Slide 8

Slide 8 text

integration_test/scrolling_test.dart import 'package:flutter/material.dart'; import 'package:flutter_application_integration_perf/main.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; void main() { final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('Perform scrolling', (WidgetTester tester) async { await tester.pumpWidget(MyApp()); await binding.traceAction( () async { final gesture = await tester .startGesture(tester.getCenter(find.byType(Scrollable))); final startTime = DateTime.now(); while (DateTime.now().difference(startTime) < const Duration(seconds: 10)) { await gesture.moveBy(const Offset(0, -10)); await Future.delayed(const Duration(milliseconds: 16)); // ը໘ϦϑϨογϡϨʔτ } // εΫϩʔϧऴྃ await gesture.up(); }, reportKey: 'scrolling_timeline', ); }); } ඵؒɺNT͝ͱʹ εΫϩʔϧ͠ଓ͚Δςετ

Slide 9

Slide 9 text

test_driver/perf_driver.dart import 'package:flutter_driver/flutter_driver.dart' as driver; import 'package:integration_test/integration_test_driver.dart'; import 'package:intl/intl.dart'; Future main() { return integrationDriver( responseDataCallback: (data) async { if (data != null) { final timeline = driver.Timeline.fromJson( data['scrolling_timeline'] as Map, ); DateTime now = DateTime.now(); // ೔࣌ΛϑΥʔϚοτ String formattedDate = DateFormat('yyyy-MM-dd_hh-mm-ss').format(now); // ϑΝΠϧ໊ʹ૊ΈࠐΉ String fileName = 'scrolling_$formattedDate'; // λΠϜϥΠϯΛɺಡΈ΍͘͢ཧղ͠΍͍͢λΠϜϥΠϯαϚϦʔʹม׵ final summary = driver.TimelineSummary.summarize(timeline); await summary.writeTimelineToFile( fileName, pretty: true, ); } }, ); } ϑΝΠϧʹग़ྗ͢Δ σϑΥϧτͩͱCVJMEʹग़·͢

Slide 10

Slide 10 text

࣮ߦͷΑ͏͢ ը૾ͷϦετΛදࣔ͢Δը໘Λ10ඵؒԼʹεΫϩʔϧ͠ଓ͚Δςετ

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

ը૾αΠζΛେ͖͘͢Δͱɺӈݞ্͕ΓʹϏϧυ͕࣌ؒ૿͍͑ͯ͘ͱ͍͏άϥϑΛ࡞Γ͔͕ͨͬͨɺͳͬͯ͘Εͳ͔ͬͨ (SleepϝιουΛڬΉͱී௨ʹͦͷ࣌ؒ෼Ճࢉ͞Εͯ͘ΕΔͷͰɺऔΕ͍ͯͳ͍Θ͚Ͱ͸ͳͦ͞͏…)

Slide 13

Slide 13 text

• Integration Test Λ࣮ߦ͢Δࡍʹ driver Λࢦఆ͢Δ͜ͱͰɺग़ྗͤ͞ Δ͜ͱ͕Ͱ͖Δ • αϯϓϧϦϙδτϦͱ͔͕ݟ͔ͭΒͳ͔ͬͨͷͰ࡞Γ·ͨ͠ • ࠷దԽ͕ޮ͍ͯ͘Ε͍ͯΔ͍͔ͤɺ͍͍ײ͡ͷςετΛ࡞Δͷ͕Ήͣ ͔͍͠ ·ͱΊ

Slide 14

Slide 14 text

• Performance pro fi ling • https://docs. fl utter.dev/cookbook/testing/integration/pro fi ling Reference