Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"url": "git+https://github.com/ChromeDevTools/trace-engine-cli.git"
},
"dependencies": {
"@paulirish/trace_engine": "^0.0.68",
"@paulirish/trace_engine": "^0.0.69",
"@toon-format/toon": "^4.1.1",
"yargs": "^18.1.0"
},
Expand Down
13 changes: 7 additions & 6 deletions src/engine/extractors/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import type { TimeRange } from '../../utils/filter.js';
import { round } from '../../utils/units.js';
import { microToMilli, milliToMicro, round } from '../../utils/units.js';
import { getRendererThread, rendererCpuFilter } from '../helpers.js';
import type { LoadedTrace } from '../loader.js';
import type { DiffEntryItem, DiffResult } from '../types.js';
Expand Down Expand Up @@ -67,8 +67,8 @@ export function extractDiff(loadedTrace: LoadedTrace, options: ExtractDiffOption
const bottomUp = new engine.Extras.TraceTree.BottomUpRootNode(mainThreadEntries, {
textFilter: { accept: () => true },
filters: [rendererCpuFilter(loadedTrace)],
startTime: engine.Types.Timing.Milli(range.startMs),
endTime: engine.Types.Timing.Milli(range.endMs),
startTime: engine.Types.Timing.Micro(milliToMicro(range.startMs)),
endTime: engine.Types.Timing.Micro(milliToMicro(range.endMs)),
});

const map = new Map<string, FnStats>();
Expand All @@ -82,15 +82,16 @@ export function extractDiff(loadedTrace: LoadedTrace, options: ExtractDiffOption

if (fnName === '(root)' || fnName === '(idle)') continue;

totalActive += node.selfTime;
const selfTimeMs = microToMilli(node.selfTime);
totalActive += selfTimeMs;
const existing = map.get(fnName);
if (existing) {
existing.selfTimeMs += node.selfTime;
existing.selfTimeMs += selfTimeMs;
} else {
map.set(fnName, {
name: fnName,
url: frame?.url,
selfTimeMs: node.selfTime,
selfTimeMs,
});
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/engine/extractors/navigations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ function buildNavigationItem(
isMainFrame: boolean,
parsedTrace: LoadedTrace['parsedTrace'],
): NavigationItem {
const url =
finalUrls?.get(navId) ||
navEvent?.args.data?.documentLoaderURL ||
navEvent?.args.data?.url ||
'';
const url = finalUrls?.get(navId) || navEvent?.args.data?.documentLoaderURL || '';
const frameId = navEvent?.args.frame;
const tsMs = round(microToMilli(navEvent?.ts ?? 0));
const insightEntry = findInsightEntry(parsedTrace, navId);
Expand Down
17 changes: 9 additions & 8 deletions src/engine/extractors/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import type { TimeRange } from '../../utils/filter.js';
import { microToMilli, round } from '../../utils/units.js';
import { microToMilli, milliToMicro, round } from '../../utils/units.js';
import {
findInsightEntry,
getRendererThread,
Expand Down Expand Up @@ -196,13 +196,14 @@ export function extractOverview(
!engine.Types.Events.isPhaseAsync(event.ph),
},
],
startTime: engine.Types.Timing.Milli(minMs),
endTime: engine.Types.Timing.Milli(maxMs),
startTime: engine.Types.Timing.Micro(milliToMicro(minMs)),
endTime: engine.Types.Timing.Micro(milliToMicro(maxMs)),
});

const children = bottomUp.children();
for (const node of children.values()) {
if (node.selfTime <= 0) continue;
const selfTimeMs = microToMilli(node.selfTime);
const name = node.event?.name || String(node.id) || '';

if (
Expand All @@ -211,9 +212,9 @@ export function extractOverview(
name === 'GCEvent' ||
name.toLowerCase().startsWith('v8.gc')
) {
breakdown.gcMs += node.selfTime;
breakdown.gcMs += selfTimeMs;
} else if (name === 'Layout' || name === 'UpdateLayoutTree' || name === 'InvalidateLayout') {
breakdown.layoutMs += node.selfTime;
breakdown.layoutMs += selfTimeMs;
} else if (
name === 'UpdateLayerTree' ||
name === 'Layerize' ||
Expand All @@ -222,7 +223,7 @@ export function extractOverview(
name === 'RasterTask' ||
name === 'DecodeImage'
) {
breakdown.renderingMs += node.selfTime;
breakdown.renderingMs += selfTimeMs;
} else if (
name === 'EvaluateScript' ||
name === 'FunctionCall' ||
Expand All @@ -234,9 +235,9 @@ export function extractOverview(
name === 'FireAnimationFrame' ||
name === 'EventDispatch'
) {
breakdown.scriptingMs += node.selfTime;
breakdown.scriptingMs += selfTimeMs;
} else {
breakdown.systemMs += node.selfTime;
breakdown.systemMs += selfTimeMs;
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/engine/extractors/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import type { TimeRange } from '../../utils/filter.js';
import { microToMilli, round } from '../../utils/units.js';
import { microToMilli, milliToMicro, round } from '../../utils/units.js';
import { getRendererThread, MISSING_CPU_SAMPLES, rendererCpuFilter } from '../helpers.js';
import type { LoadedTrace } from '../loader.js';
import type { ProfileResult } from '../types.js';
Expand Down Expand Up @@ -66,8 +66,8 @@ export function extractProfile(
const bottomUp = new engine.Extras.TraceTree.BottomUpRootNode(mainThread.entries, {
textFilter: { accept: () => true },
filters: [cpuFilter],
startTime: engine.Types.Timing.Milli(currentStart),
endTime: engine.Types.Timing.Milli(currentEnd),
startTime: engine.Types.Timing.Micro(milliToMicro(currentStart)),
endTime: engine.Types.Timing.Micro(milliToMicro(currentEnd)),
});

const funcList: Array<{ name: string; url?: string; selfTimeMs: number }> = [];
Expand All @@ -82,11 +82,12 @@ export function extractProfile(
// Exclude generic root markers from active work
if (fnName === '(root)' || fnName === '(idle)') continue;

totalActiveMs += node.selfTime;
const selfTimeMs = microToMilli(node.selfTime);
totalActiveMs += selfTimeMs;
funcList.push({
name: fnName,
url: frame?.url || undefined,
selfTimeMs: round(node.selfTime),
selfTimeMs: round(selfTimeMs),
});
}

Expand Down
14 changes: 8 additions & 6 deletions src/engine/extractors/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import { isEventInBounds, type TimeRange } from '../../utils/filter.js';
import { microToMilli, round } from '../../utils/units.js';
import { microToMilli, milliToMicro, round } from '../../utils/units.js';
import { getRendererThread, MISSING_CPU_SAMPLES, rendererCpuFilter } from '../helpers.js';
import type { LoadedTrace } from '../loader.js';
import type { TaskItem, TasksResult } from '../types.js';
Expand Down Expand Up @@ -52,8 +52,10 @@ export function extractTasks(loadedTrace: LoadedTrace, options?: ExtractTasksOpt

const traceBounds = parsedTrace.data.Meta.traceBounds;
const treeOptions = {
startTime: engine.Types.Timing.Milli(timeRange?.startMs ?? microToMilli(traceBounds.min)),
endTime: engine.Types.Timing.Milli(timeRange?.endMs ?? microToMilli(traceBounds.max)),
startTime: engine.Types.Timing.Micro(
timeRange ? milliToMicro(timeRange.startMs) : traceBounds.min,
),
endTime: engine.Types.Timing.Micro(timeRange ? milliToMicro(timeRange.endMs) : traceBounds.max),
};
const traceTree = engine.Extras.TraceTree;
const cpuFilter = rendererCpuFilter(loadedTrace);
Expand All @@ -68,8 +70,8 @@ export function extractTasks(loadedTrace: LoadedTrace, options?: ExtractTasksOpt
);
return {
startTimeMs: round(microToMilli(firstTs)),
durationMs: round(node.totalTime),
selfTimeMs: round(node.selfTime),
durationMs: round(microToMilli(node.totalTime)),
selfTimeMs: round(microToMilli(node.selfTime)),
functionName: frame?.functionName || node.event.name,
url: frame?.url || undefined,
lineNumber: frame?.lineNumber,
Expand All @@ -87,7 +89,7 @@ export function extractTasks(loadedTrace: LoadedTrace, options?: ExtractTasksOpt
const candidates: Array<{ node: TreeNode; score: number }> = [];
for (const node of bottomUp.children().values()) {
if (node.selfTime > 0 && (!urlOnly || traceTree.eventStackFrame(node.event)?.url)) {
candidates.push({ node, score: round(node.selfTime) });
candidates.push({ node, score: round(microToMilli(node.selfTime)) });
// Trim in batches to bound memory and sort work for a small --top.
if (candidates.length === top * 2) rankAndLimit(candidates, top);
}
Expand Down
Loading