Skip to content

Commit

Permalink
Post-review2 commit: Add a simple test to check a good behavior in th…
Browse files Browse the repository at this point in the history
…e sidebar for categories in a diffing track
  • Loading branch information
julienw committed Jul 12, 2019
1 parent f8fe7db commit e349f1c
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/test/unit/profile-data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ensureExists } from '../../utils/flow';
import getCallNodeProfile from '../fixtures/profiles/call-nodes';
import {
getProfileFromTextSamples,
getMergedProfileFromTextSamples,
getJsTracerTable,
} from '../fixtures/profiles/processed-profile';
import { funcHasRecursiveCall } from '../../profile-logic/transforms';
Expand Down Expand Up @@ -1176,6 +1177,70 @@ describe('getTimingsForPath for an inverted tree', function() {
});
});

describe('getTimingsForPath for a diffing track', function() {
function setup() {
const { profile, funcNamesDictPerThread } = getMergedProfileFromTextSamples(
`
A A A
B B C
D[cat:Layout] E F
`,
`
A A A
B B B
G[cat:JavaScript] I E
`
);
const defaultCategory = profile.meta.categories.findIndex(
c => c.name === 'Other'
);
const thread = profile.threads[2];

const callNodeInfo = getCallNodeInfo(
thread.stackTable,
thread.frameTable,
thread.funcTable,
defaultCategory
);
const curriedGetTimingsForPath = path =>
getTimingsForPath(
path,
callNodeInfo,
profile.meta.interval,
false /* inverted tree */,
thread,
profile.meta.categories
);

return {
getTimingsForPath: curriedGetTimingsForPath,
funcNamesDictPerThread,
};
}

it('computes the right breakdowns', () => {
const {
getTimingsForPath,
funcNamesDictPerThread: [{ A }],
} = setup();
const timings = getTimingsForPath([A]);
expect(timings.forPath).toEqual({
selfTime: {
breakdownByCategory: null,
breakdownByImplementation: null,
value: 0,
},
totalTime: {
breakdownByCategory: withSingleSubcategory([0, 0, -1, 1, 0, 0, 0, 0]), // Idle, Other, Layout, JavaScript, etc.
breakdownByImplementation: {
native: 0,
},
value: 0,
},
});
});
});

describe('getSamplesSelectedStates', function() {
const {
profile,
Expand Down

0 comments on commit e349f1c

Please sign in to comment.