Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
task: () => {
trace = loadTrace(events.traceEvents);
},
title: 'Loading Trace',
let trace: any = null;
let totalDuration: number = 0;
const { flags } = this.parse(CSSParse);
const { traceJSONOutput } = flags;
try {
events = JSON.parse(fs.readFileSync(traceJSONOutput, 'utf8'));
} catch (error) {
this.error(
`Could not extract trace events from trace JSON file at path ${traceJSONOutput}, ${error}`
);
}
try {
trace = loadTrace(events.traceEvents);
} catch (error) {
this.error(error);
}
trace.events
.filter((event: any) => event.name === 'ParseAuthorStyleSheet')
.filter((event: any) => event.args.data.styleSheetUrl)
.forEach((event: any) => {
const url = event.args.data.styleSheetUrl;
const durationInMs = event.dur / 1000;
totalDuration += durationInMs;
this.log(`CSS: ${url}: ${durationInMs.toFixed(2)}`);
});
this.log(`TOTAL DURATION: ${totalDuration.toFixed(2)}ms`);
}
let profile: any = null;
const { flags } = this.parse(ListFunctions);
const { traceJSONOutput, locations } = flags;
const methods = new Set();
try {
events = JSON.parse(fs.readFileSync(traceJSONOutput, 'utf8'));
} catch (error) {
this.error(
`Could not extract trace events from trace file at path ${traceJSONOutput}, ${error}`
);
}
try {
trace = loadTrace(events.traceEvents);
} catch (error) {
this.error(error);
}
try {
profile = trace.cpuProfile(-1, -1);
} catch (error) {
this.error(error);
}
if (locations) {
profile.nodeMap.forEach((node: any) => {
const { functionName, url, lineNumber, columnNumber } = node.callFrame;
methods.add(
`${url}:${lineNumber}:${columnNumber}.${normalizeFnName(
const file = traceJSONOutput;
let archiveFile;
let rawTraceData;
try {
rawTraceData = JSON.parse(fs.readFileSync(traceJSONOutput, 'utf8'));
} catch (error) {
this.error(`Could not find file: ${traceJSONOutput}, ${error}`);
}
try {
archiveFile = JSON.parse(fs.readFileSync(archive, 'utf8'));
} catch (error) {
this.error(`Could not find archive file: ${archive}, ${error}`);
}
await analyze({
archiveFile,
event,
file,
methods,
rawTraceData,
report,
});
}
}