Skip to content

Support filtering CPU profiles by UserTags - #2988

Merged
kenzieschmoll merged 9 commits into
flutter:masterfrom
kenzieschmoll:userTag
May 6, 2021
Merged

kenzieschmoll merged 9 commits into
flutter:masterfrom
kenzieschmoll:userTag

Conversation

@kenzieschmoll

Copy link
Copy Markdown
Member

If a user specifies UserTags in their code, those tags will show up in the DevTools CPU profiler as filter options.
filter-by-user-tag
Fixes #2964
Fixes #947

@kenzieschmoll
kenzieschmoll requested review from bkonyi and jacob314 May 6, 2021 20:05
Comment thread packages/devtools_app/lib/src/profiler/cpu_profile_controller.dart

Iterable<String> get userTags => _dataByTag[userTagNone]?.userTags ?? [];

int selectedProfilerTabIndex = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this a value listenable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a value listenable because nothing needs to be rebuild when this changes. We are already rebuilding when the _tabController has changes. selectedProfilerTabIndex is only accessed by _CpuProfilerState one time in initState, so we don't need to listen to changes to it.

Comment thread packages/devtools_app/lib/src/profiler/cpu_profile_controller.dart Outdated
Comment thread packages/devtools_app/lib/src/profiler/cpu_profile_model.dart Outdated
Comment thread packages/devtools_app/lib/src/profiler/cpu_profiler.dart
value: tag,
),
],
onChanged: userTags.isNotEmpty ? _onUserTagChanged : null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be items.length > 1 instead of userTags.isNotEmpty?
I expect you don't really want this to be selectable if the only tag was the default tag.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what this code is doing. items above will always have one item because we are showing a none option to negate any filters and show all samples. Then after that item, we will add the items from userTags, so if userTags is empty, items will have length 1 with just the none option. If userTags has length 1, then the two options we'd want to show are the one user tag and the none item.

Comment thread packages/devtools_app/test/cpu_profiler_controller_test.dart Outdated

@jacob314 jacob314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick first pass

Comment thread packages/devtools_app/lib/src/performance/performance_controller.dart Outdated
Comment thread packages/devtools_app/lib/src/profiler/cpu_profile_controller.dart Outdated
Comment thread packages/devtools_app/lib/src/profiler/cpu_profile_transformer.dart
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:developer';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this import for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for accessing UserTag.defaultTag

@kenzieschmoll
kenzieschmoll merged commit d67ed9e into flutter:master May 6, 2021
@kenzieschmoll
kenzieschmoll deleted the userTag branch May 6, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support UserTags in the DevTools CPU profiler CPU profiler start and end times should be able to be configured in user code

3 participants