@ohos-perf/cli 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +123 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -275,6 +275,14 @@ async function runUiCompare(deps2, req, opts) {
|
|
|
275
275
|
}
|
|
276
276
|
lines.push(`regions ${result.regions}
|
|
277
277
|
`);
|
|
278
|
+
if (result.image === null) {
|
|
279
|
+
lines.push("animations not measured (no screenshots on either side)\n");
|
|
280
|
+
} else {
|
|
281
|
+
lines.push(
|
|
282
|
+
`animations ${result.animations} labelled, ${result.pixelOnly} pixel-only, ${result.unmeasuredRegions} unmeasured
|
|
283
|
+
`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
278
286
|
for (const line of result.degraded) lines.push(`degraded ${line}
|
|
279
287
|
`);
|
|
280
288
|
lines.push(`wrote ${result.files.join(", ")} in ${result.outDir}
|
|
@@ -309,6 +317,39 @@ artifacts ${result.files.join(" ")}
|
|
|
309
317
|
`, exitCode: 1 };
|
|
310
318
|
}
|
|
311
319
|
}
|
|
320
|
+
async function runTrend(deps2, req, opts) {
|
|
321
|
+
if (req.reports.length < 2) {
|
|
322
|
+
return {
|
|
323
|
+
stdout: "",
|
|
324
|
+
stderr: `trend needs at least two reports; got ${req.reports.length}. A trend of one is a report \u2014 use \`report\` for a single run.
|
|
325
|
+
`,
|
|
326
|
+
exitCode: 1
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
const result = await deps2.trend({
|
|
331
|
+
...req,
|
|
332
|
+
reports: req.reports.map((report) => ({
|
|
333
|
+
label: report.label ?? report.path,
|
|
334
|
+
path: report.path
|
|
335
|
+
}))
|
|
336
|
+
});
|
|
337
|
+
if (opts.json) return { stdout: json(result), stderr: "", exitCode: 0 };
|
|
338
|
+
const order = result.orderedBy === "startedAtNs" ? "ordered by capture start time" : "ordered by argument (a run has no capture start time)";
|
|
339
|
+
return {
|
|
340
|
+
stdout: `trend ${result.outDir}/trend.html
|
|
341
|
+
artifacts ${result.files.join(" ")}
|
|
342
|
+
runs ${result.runs.length} (${result.runs.map((run) => run.label).join(", ")}) \xB7 ${order}
|
|
343
|
+
series ${result.series} metrics \xB7 ${result.improved} improved, ${result.regressed} regressed, ${result.unchanged} unchanged, ${result.verdictless} without a known direction
|
|
344
|
+
`,
|
|
345
|
+
stderr: "",
|
|
346
|
+
exitCode: 0
|
|
347
|
+
};
|
|
348
|
+
} catch (err) {
|
|
349
|
+
return { stdout: "", stderr: `${failureLine(err)}
|
|
350
|
+
`, exitCode: 1 };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
312
353
|
async function runHap(deps2, req, opts) {
|
|
313
354
|
const pathError = packagePathError(req.packagePath);
|
|
314
355
|
if (pathError !== void 0) return { stdout: "", stderr: `${pathError}
|
|
@@ -638,6 +679,7 @@ import {
|
|
|
638
679
|
parseHilogText,
|
|
639
680
|
analyzeHap,
|
|
640
681
|
buildReport,
|
|
682
|
+
buildTrend,
|
|
641
683
|
compareResults,
|
|
642
684
|
compareSceneDirs,
|
|
643
685
|
UI_DIFF_FILES,
|
|
@@ -647,6 +689,9 @@ import {
|
|
|
647
689
|
renderReportJson,
|
|
648
690
|
renderReportXlsx,
|
|
649
691
|
renderSummaryJson,
|
|
692
|
+
renderTrendHtml,
|
|
693
|
+
renderTrendJson,
|
|
694
|
+
trendRunFromReport,
|
|
650
695
|
renderFlamegraphHtml,
|
|
651
696
|
renderFlamegraphSvg,
|
|
652
697
|
hapSection,
|
|
@@ -1035,6 +1080,9 @@ function realDeps(version = packageVersion(), overrides = {}) {
|
|
|
1035
1080
|
tolerance: diff.image.tolerance
|
|
1036
1081
|
},
|
|
1037
1082
|
regions: diff.regions.length,
|
|
1083
|
+
animations: diff.animations.length,
|
|
1084
|
+
pixelOnly: diff.pixelOnly.length,
|
|
1085
|
+
unmeasuredRegions: diff.unmeasuredRegions.length,
|
|
1038
1086
|
degraded: [...diff.degraded]
|
|
1039
1087
|
};
|
|
1040
1088
|
},
|
|
@@ -1107,6 +1155,57 @@ function realDeps(version = packageVersion(), overrides = {}) {
|
|
|
1107
1155
|
...model.comparison === void 0 ? {} : { comparison: { ...model.comparison.totals } }
|
|
1108
1156
|
};
|
|
1109
1157
|
},
|
|
1158
|
+
async trend(req) {
|
|
1159
|
+
const runs = req.reports.map((report) => {
|
|
1160
|
+
const file = report.path.endsWith(".json") ? report.path : join2(report.path, "report.json");
|
|
1161
|
+
let parsed;
|
|
1162
|
+
try {
|
|
1163
|
+
parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
1164
|
+
} catch (err) {
|
|
1165
|
+
throw new OhosPerfError3(
|
|
1166
|
+
`cannot read report ${file}: ${safeMessage(err)}`,
|
|
1167
|
+
{ code: "TREND_BAD_INPUT", cause: err }
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1170
|
+
const model = parsed;
|
|
1171
|
+
if (!Array.isArray(model.sections) || model.scenario === void 0) {
|
|
1172
|
+
throw new OhosPerfError3(
|
|
1173
|
+
`${file} is not a report document (no sections or scenario block)`,
|
|
1174
|
+
{ code: "TREND_BAD_INPUT" }
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
return trendRunFromReport(report.label ?? report.path, model);
|
|
1178
|
+
});
|
|
1179
|
+
const trend = buildTrend(runs);
|
|
1180
|
+
const outDir = resolve(req.outDir);
|
|
1181
|
+
const artifacts = [
|
|
1182
|
+
["trend.html", renderTrendHtml(trend)],
|
|
1183
|
+
["trend.json", renderTrendJson(trend)]
|
|
1184
|
+
];
|
|
1185
|
+
await mkdir(outDir, { recursive: true });
|
|
1186
|
+
for (const [name, content] of artifacts) {
|
|
1187
|
+
await writeFile(join2(outDir, name), content);
|
|
1188
|
+
}
|
|
1189
|
+
const count = (status) => trend.series.filter((series) => series.status === status).length;
|
|
1190
|
+
const verdictless = trend.series.filter((series) => series.status === void 0).length;
|
|
1191
|
+
return {
|
|
1192
|
+
outDir,
|
|
1193
|
+
files: artifacts.map(([name]) => name),
|
|
1194
|
+
runs: trend.runs.map((run) => ({
|
|
1195
|
+
label: run.label,
|
|
1196
|
+
app: run.app,
|
|
1197
|
+
device: run.device,
|
|
1198
|
+
...run.startedAtNs === void 0 ? {} : { startedAtNs: run.startedAtNs },
|
|
1199
|
+
metrics: run.metrics.length
|
|
1200
|
+
})),
|
|
1201
|
+
orderedBy: trend.orderedBy,
|
|
1202
|
+
series: trend.series.length,
|
|
1203
|
+
improved: count("improved"),
|
|
1204
|
+
regressed: count("regressed"),
|
|
1205
|
+
unchanged: count("unchanged"),
|
|
1206
|
+
verdictless
|
|
1207
|
+
};
|
|
1208
|
+
},
|
|
1110
1209
|
async hap(req) {
|
|
1111
1210
|
const analysis = analyzeHap(readFileSync2(req.packagePath), basename(req.packagePath));
|
|
1112
1211
|
const capabilities = [{
|
|
@@ -1345,6 +1444,11 @@ function parseOnly(raw) {
|
|
|
1345
1444
|
return ids;
|
|
1346
1445
|
}
|
|
1347
1446
|
|
|
1447
|
+
// src/trend.ts
|
|
1448
|
+
function collectLabels(raw, previous) {
|
|
1449
|
+
return [...previous ?? [], raw];
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1348
1452
|
// src/program.ts
|
|
1349
1453
|
function targetOptionsOf(opts) {
|
|
1350
1454
|
return {
|
|
@@ -1481,6 +1585,25 @@ function buildProgram(deps2, io, opts = {}) {
|
|
|
1481
1585
|
);
|
|
1482
1586
|
}
|
|
1483
1587
|
);
|
|
1588
|
+
program2.command("trend").description("aggregate two or more saved reports into one trend page").argument("<reports...>", "report.json files or report bundle directories (at least two)").requiredOption("--out <dir>", "output directory for trend.html and trend.json").option(
|
|
1589
|
+
"--label <label>",
|
|
1590
|
+
"a run label, repeated once per report in order (default: the report path)",
|
|
1591
|
+
collectLabels
|
|
1592
|
+
).option("--json", "print the trend manifest as JSON").action(async (reports, opts2) => {
|
|
1593
|
+
io.emit(
|
|
1594
|
+
await runTrend(
|
|
1595
|
+
deps2,
|
|
1596
|
+
{
|
|
1597
|
+
reports: reports.map((path, index) => {
|
|
1598
|
+
const label = opts2.label?.[index];
|
|
1599
|
+
return { path, ...label === void 0 ? {} : { label } };
|
|
1600
|
+
}),
|
|
1601
|
+
outDir: opts2.out
|
|
1602
|
+
},
|
|
1603
|
+
{ json: opts2.json }
|
|
1604
|
+
)
|
|
1605
|
+
);
|
|
1606
|
+
});
|
|
1484
1607
|
program2.command("hap").description("inspect a .hap/.hsp package offline: files, sizes, technologies, duplicates").argument("<package>", "path to a .hap, .hsp or .zip file").option("--out <dir>", "write hap.json and hap.html to this directory").option("--json", "print the analysis as JSON").action(async (packagePath, opts2) => {
|
|
1485
1608
|
io.emit(
|
|
1486
1609
|
await runHap(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-perf/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Command-line interface for HarmonyOS performance analysis: doctor, caps, collect, analyze, query, tools, compare, report, gesture, emulator and selector-driven scenarios",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"harmonyos",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ohos-perf/core": "0.
|
|
39
|
+
"@ohos-perf/core": "0.16.0",
|
|
40
40
|
"commander": "^12.1.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|