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
11 changes: 6 additions & 5 deletions dial9-viewer/ui/test_trace_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ async function main() {
trace.hasSchedWait,
{}
);
if (pois.length === 0) fail("No long-poll points of interest found");
for (const p of pois) {
if (p.type !== "long-poll") fail(`Wrong type: ${p.type}`);
if (p.value <= 1) fail(`long-poll value ${p.value} <= 1ms`);
Expand All @@ -290,6 +291,7 @@ async function main() {
trace.hasSchedWait,
{}
);
if (pois.length === 0) fail("No cpu-sampled points of interest found");
for (const p of pois) {
if (p.type !== "cpu-sampled") fail(`Wrong type: ${p.type}`);
if (p.value <= 0) fail(`cpu-sampled value ${p.value} <= 0`);
Expand All @@ -306,6 +308,7 @@ async function main() {
trace.hasSchedWait,
{}
);
if (pois.length === 0) fail("No wake-delay points of interest found");
for (const p of pois) {
if (p.type !== "wake-delay") fail(`Wrong type: ${p.type}`);
if (p.value <= 100) fail(`wake-delay value ${p.value} <= 100µs`);
Expand All @@ -332,8 +335,7 @@ async function main() {

function testFlamegraphTree() {
const cpuSamples = trace.cpuSamples.filter((s) => s.source !== 1);
if (cpuSamples.length === 0)
return pass("No CPU samples to test flamegraph");
if (cpuSamples.length === 0) fail("No CPU samples found");

const root = buildFlamegraphTree(cpuSamples, trace.callframeSymbols);
if (root.count !== cpuSamples.length)
Expand All @@ -343,7 +345,7 @@ async function main() {

function testFlattenFlamegraph() {
const cpuSamples = trace.cpuSamples.filter((s) => s.source !== 1);
if (cpuSamples.length === 0) return pass("No CPU samples to test flatten");
if (cpuSamples.length === 0) fail("No CPU samples found");

const root = buildFlamegraphTree(cpuSamples, trace.callframeSymbols);
const { nodes, maxDepth } = flattenFlamegraph(root, cpuSamples.length);
Expand All @@ -357,8 +359,7 @@ async function main() {

function testBuildFgData() {
const cpuSamples = trace.cpuSamples.filter((s) => s.source !== 1);
if (cpuSamples.length === 0)
return pass("No CPU samples to test buildFgData");
if (cpuSamples.length === 0) fail("No CPU samples found");

const data = buildFgData(cpuSamples, trace.callframeSymbols);
if (!data) fail("buildFgData returned null for non-empty samples");
Expand Down
5 changes: 4 additions & 1 deletion dial9-viewer/ui/test_trace_integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ async function main() {
(e) => e.eventType === EVENT_TYPES.WakeEvent
);
const outOfRangeWorker = wakeEvents.find(
(e) => e.targetWorker !== 255 && e.targetWorker > maxWorkerId
(e) =>
e.targetWorker !== 255 && // UNKNOWN
e.targetWorker !== 254 && // BLOCKING
e.targetWorker > maxWorkerId
);
if (outOfRangeWorker)
fail(
Expand Down
6 changes: 4 additions & 2 deletions dial9-viewer/ui/trace_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
/** Parse a string/bigint/number to a JS number */
function num(v) {
if (typeof v === "number") return v;
if (typeof v === "string") return Number(v);
if (typeof v === "bigint") return Number(v);
return 0;
if (typeof v === "string" && v !== "")
if (!isNaN(Number(v))) return Number(v);

throw new Error(`Invalid number: ${v}`);
}

/** Decompress gzip data if detected, otherwise return as-is. */
Expand Down
Loading