add "c" shortcut to slice a profile

This commit is contained in:
Tobias Koppers 2021-09-27 11:11:24 +02:00
parent e37f6fa7c3
commit b08cdf20f1
3 changed files with 39 additions and 0 deletions

View File

@ -119,6 +119,7 @@ Once a profile has loaded, the main view is split into two: the top area is the
* `n`: Go to next profile/thread if one is available * `n`: Go to next profile/thread if one is available
* `p`: Go to previous profile/thread if one is available * `p`: Go to previous profile/thread if one is available
* `t`: Open the profile/thread selector if available * `t`: Open the profile/thread selector if available
* `c`: Slice the profile by the current selecting in "Time Order" view
* `Cmd+F`/`Ctrl+F`: to open search. While open, `Enter` and `Shift+Enter` cycle through results * `Cmd+F`/`Ctrl+F`: to open search. While open, `Enter` and `Shift+Enter` cycle through results
## Contributing ## Contributing

View File

@ -328,6 +328,33 @@ export class Profile {
return flattenedProfile return flattenedProfile
} }
getProfileSlice(start: number, end: number): Profile {
const builder = new CallTreeProfileBuilder()
let lastValue = 0
function openFrame(node: CallTreeNode, value: number) {
builder.enterFrame(
node.frame,
(lastValue = value >= end || value < start ? lastValue : value - start),
)
}
function closeFrame(node: CallTreeNode, value: number) {
builder.leaveFrame(
node.frame,
(lastValue = value >= end || value < start ? lastValue : value - start),
)
}
this.forEachCall(openFrame, closeFrame)
const slice = builder.build()
slice.name = this.name
slice.valueFormatter = this.valueFormatter
return slice
}
getInvertedProfileForCallersOf(focalFrameInfo: FrameInfo): Profile { getInvertedProfileForCallersOf(focalFrameInfo: FrameInfo): Profile {
const focalFrame = Frame.getOrInsert(this.frames, focalFrameInfo) const focalFrame = Frame.getOrInsert(this.frames, focalFrameInfo)
const builder = new StackListProfileBuilder() const builder = new StackListProfileBuilder()

View File

@ -349,6 +349,17 @@ export class Application extends StatelessComponent<ApplicationProps> {
if (activeProfileState) { if (activeProfileState) {
this.props.setProfileIndexToView(activeProfileState.index - 1) this.props.setProfileIndexToView(activeProfileState.index - 1)
} }
} else if (ev.key === 'c') {
const {activeProfileState, profileGroup, setProfileGroup} = this.props
if (activeProfileState && profileGroup) {
const start = activeProfileState.chronoViewState.configSpaceViewportRect.origin.x
const end = start + activeProfileState.chronoViewState.configSpaceViewportRect.size.x
setProfileGroup({
name: profileGroup.name,
indexToView: 0,
profiles: [activeProfileState.profile.getProfileSlice(start, end)],
})
}
} }
} }