text stringlengths 1 372 |
|---|
to the firebase TestLab section of the firebase console. |
<topic_end> |
<topic_start> |
uploading xcode tests from the command line |
see the iOS device testing section in the README |
for instructions on how to upload the .zip file |
from the command line. |
<topic_end> |
<topic_start> |
performance profiling |
when it comes to mobile apps, performance is critical to user experience. |
users expect apps to have smooth scrolling and meaningful animations free of |
stuttering or skipped frames, known as “jank.” how to ensure that your app |
is free of jank on a wide variety of devices? |
there are two options: first, manually test the app on different devices. |
while that approach might work for a smaller app, it becomes more |
cumbersome as an app grows in size. alternatively, run an integration |
test that performs a specific task and records a performance timeline. |
then, examine the results to determine whether a specific section of |
the app needs to be improved. |
in this recipe, learn how to write a test that records a performance |
timeline while performing a specific task and saves a summary of the |
results to a local file. |
info note |
recording performance timelines isn’t supported on web. |
for performance profiling on web, see |
debugging performance for web apps |
this recipe uses the following steps: |
<topic_end> |
<topic_start> |
1. write a test that scrolls through a list of items |
in this recipe, record the performance of an app as it scrolls through a |
list of items. to focus on performance profiling, this recipe builds |
on the scrolling recipe in widget tests. |
follow the instructions in that recipe to create an app and write a test to |
verify that everything works as expected. |
<topic_end> |
<topic_start> |
2. record the performance of the app |
next, record the performance of the app as it scrolls through the |
list. perform this task using the traceAction() |
method provided by the IntegrationTestWidgetsFlutterBinding class. |
this method runs the provided function and records a timeline |
with detailed information about the performance of the app. this example |
provides a function that scrolls through the list of items, |
ensuring that a specific item is displayed. when the function completes, |
the traceAction() creates a report data map that contains the timeline. |
specify the reportKey when running more than one traceAction. |
by default all timelines are stored with the key timeline, |
in this example the reportKey is changed to scrolling_timeline. |
<code_start> |
await binding.traceAction( |
() async { |
// scroll until the item to be found appears. |
await tester.scrollUntilVisible( |
itemFinder, |
500.0, |
scrollable: listFinder, |
); |
}, |
reportKey: 'scrolling_timeline', |
); |
<code_end> |
<topic_end> |
<topic_start> |
3. save the results to disk |
now that you’ve captured a performance timeline, you need a way to review it. |
the timeline object provides detailed information about all of the events |
that took place, but it doesn’t provide a convenient way to review the results. |
therefore, convert the timeline into a TimelineSummary. |
the TimelineSummary can perform two tasks that make it easier |
to review the results: |
to capture the results, create a file named perf_driver.dart |
in the test_driver folder and add the following code: |
<code_start> |
import 'package:flutter_driver/flutter_driver.dart' as driver; |
import 'package:integration_test/integration_test_driver.dart'; |
future<void> main() { |
return integrationDriver( |
responseDataCallback: (data) async { |
if (data != null) { |
final timeline = driver.Timeline.fromJson( |
data['scrolling_timeline'] as Map<String, dynamic>, |
); |
// convert the timeline into a TimelineSummary that's easier to |
// read and understand. |
final summary = driver.TimelineSummary.summarize(timeline); |
// then, write the entire timeline to disk in a json format. |
// this file can be opened in the chrome browser's tracing tools |
// found by navigating to chrome://tracing. |
// optionally, save the summary to disk by setting includeSummary |
// to true |
await summary.writeTimelineToFile( |
'scrolling_timeline', |
pretty: true, |
includeSummary: true, |
); |
} |
}, |
); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.