Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellanoce authored and github-actions[bot] committed Apr 10, 2023
1 parent 79e113e commit 3b7ded7
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions packages/rrweb/test/benchmark/dom-mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,36 +117,40 @@ describe('benchmark: mutation observer', () => {
};

const getDuration = async (): Promise<number> => {
return (await page.evaluate((triggerWorkloadScript, recordOptions) => {
return new Promise((resolve, reject) => {
let start = 0;
let lastEvent: eventWithTime | null;
const options: recordOptions<eventWithTime> = {
...recordOptions,
emit: (event) => {
// console.log(event.type, event.timestamp);
if (event.type !== 5 || event.data.tag !== 'FTAG') {
lastEvent = event;
return;
}
if (!lastEvent) {
reject('no events recorded');
return;
}
resolve(lastEvent.timestamp - start);
},
};
const record = (window as any).rrweb.record;
record(options);

start = Date.now();
eval(triggerWorkloadScript);

requestAnimationFrame(() => {
record.addCustomEvent('FTAG', {});
return (await page.evaluate(
(triggerWorkloadScript, recordOptions) => {
return new Promise((resolve, reject) => {
let start = 0;
let lastEvent: eventWithTime | null;
const options: recordOptions<eventWithTime> = {
...recordOptions,
emit: (event) => {
// console.log(event.type, event.timestamp);
if (event.type !== 5 || event.data.tag !== 'FTAG') {
lastEvent = event;
return;
}
if (!lastEvent) {
reject('no events recorded');
return;
}
resolve(lastEvent.timestamp - start);
},
};
const record = (window as any).rrweb.record;
record(options);

start = Date.now();
eval(triggerWorkloadScript);

requestAnimationFrame(() => {
record.addCustomEvent('FTAG', {});
});
});
});
}, suite.eval, suite.recordOptions || {})) as number;
},
suite.eval,
suite.recordOptions || {},
)) as number;
};

// generate profile.json file
Expand Down

0 comments on commit 3b7ded7

Please sign in to comment.