Skip to content

Commit c567f1f

Browse files
committed
Fix correctness issues in timing
1 parent 09db021 commit c567f1f

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/profile-logic/merge-compare.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,14 @@ export function mergeProfilesForDiffing(
218218
// We adjust the various times so that the 2 profiles are aligned at the
219219
// start and the data is consistent.
220220
let startTimeAdjustment = 0;
221-
if (thread.samples.length !== 0) {
221+
if (thread.samples.length) {
222222
startTimeAdjustment = -thread.samples.time[0];
223-
}
224-
if (thread.markers.length !== 0) {
223+
} else if (thread.markers.length) {
225224
for (const startTime of thread.markers.startTime) {
225+
// Find the first marker startTime.
226226
if (startTime !== null) {
227-
if (startTimeAdjustment === 0) {
228-
startTimeAdjustment = startTime;
229-
} else {
230-
startTimeAdjustment = Math.min(startTime, startTimeAdjustment);
231-
}
227+
startTimeAdjustment = -startTime;
228+
break;
232229
}
233230
}
234231
}

src/test/store/actions.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ describe('selectors/getThreadRange', function () {
518518
);
519519

520520
expect(selectedThreadSelectors.getThreadRange(getState())).toEqual({
521-
start: 10,
522-
end: 21,
521+
start: 0,
522+
end: 11,
523523
});
524524
});
525525

src/test/unit/merge-compare.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ describe('mergeProfilesForDiffing function', function () {
261261
]);
262262

263263
expect(getTimeRangeIncludingAllThreads(profile)).toEqual({
264-
end: 21,
265-
start: 4,
264+
start: 0,
265+
end: 11,
266266
});
267267
});
268268
});

0 commit comments

Comments
 (0)