Skip to content

Commit

Permalink
Post-review2 commit: Make getMergedProfileFromTextSamples return the …
Browse files Browse the repository at this point in the history
…func indexes
  • Loading branch information
julienw committed Jul 12, 2019
1 parent a818a72 commit f8fe7db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
23 changes: 19 additions & 4 deletions src/test/fixtures/profiles/processed-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,32 @@ function _buildThreadFromTextOnlyStacks(
/**
* This returns a merged profile from a number of profile strings.
*/
export function getMergedProfileFromTextSamples(...profileStrings: string[]) {
const profiles = profileStrings.map(
str => getProfileFromTextSamples(str).profile
export function getMergedProfileFromTextSamples(
...profileStrings: string[]
): {
profile: Profile,
funcNamesPerThread: Array<string[]>,
funcNamesDictPerThread: Array<{ [funcName: string]: number }>,
} {
const profilesAndFuncNames = profileStrings.map(str =>
getProfileFromTextSamples(str)
);
const profiles = profilesAndFuncNames.map(({ profile }) => profile);
const profileState = stateFromLocation({
pathname: '/public/fakehash1/',
search: '?thread=0&v=3',
hash: '',
});
const { profile } = mergeProfiles(profiles, profiles.map(() => profileState));
return profile;
return {
profile,
funcNamesPerThread: profilesAndFuncNames.map(
({ funcNamesPerThread }) => funcNamesPerThread[0]
),
funcNamesDictPerThread: profilesAndFuncNames.map(
({ funcNamesDictPerThread }) => funcNamesDictPerThread[0]
),
};
}

type NetworkMarkersOptions = {|
Expand Down
5 changes: 4 additions & 1 deletion src/test/store/profile-view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,10 @@ describe('actions/ProfileView', function() {
trackIndex: 2,
};

const profile = getMergedProfileFromTextSamples('A B C', 'A B B');
const { profile } = getMergedProfileFromTextSamples(
'A B C',
'A B B'
);
const { getState, dispatch } = storeWithProfile(profile);

dispatch(App.changeSelectedTab('flame-graph'));
Expand Down
2 changes: 1 addition & 1 deletion src/test/store/useful-tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('getUsefulTabs', function() {
});

it('shows only the call tree when a diffing track is selected', function() {
const profile = getMergedProfileFromTextSamples('A B C', 'A B B');
const { profile } = getMergedProfileFromTextSamples('A B C', 'A B B');
const { getState, dispatch } = storeWithProfile(profile);
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/profile-tree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ describe('inverted call tree', function() {

describe('diffing trees', function() {
function getProfile() {
const profile = getMergedProfileFromTextSamples(
const { profile } = getMergedProfileFromTextSamples(
`
A A A
B B C
Expand Down

0 comments on commit f8fe7db

Please sign in to comment.