Skip to content

Commit 7b1971e

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

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
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/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)