@ohos-perf/cli 0.16.0 → 0.17.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 +54 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -350,6 +350,24 @@ series ${result.series} metrics \xB7 ${result.improved} improved, ${result.regr
|
|
|
350
350
|
`, exitCode: 1 };
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
+
async function runRender(deps2, req, opts) {
|
|
354
|
+
try {
|
|
355
|
+
const result = await deps2.render(req);
|
|
356
|
+
if (opts.json) return { stdout: json(result), stderr: "", exitCode: 0 };
|
|
357
|
+
return {
|
|
358
|
+
stdout: `report ${result.outDir}/report.html
|
|
359
|
+
artifacts ${result.files.join(" ")}
|
|
360
|
+
sections ${result.sections} \xB7 ${result.metrics} metrics \xB7 ${result.evidence} evidence
|
|
361
|
+
source ${req.report} (re-rendered, not re-analyzed)
|
|
362
|
+
`,
|
|
363
|
+
stderr: "",
|
|
364
|
+
exitCode: 0
|
|
365
|
+
};
|
|
366
|
+
} catch (err) {
|
|
367
|
+
return { stdout: "", stderr: `${failureLine(err)}
|
|
368
|
+
`, exitCode: 1 };
|
|
369
|
+
}
|
|
370
|
+
}
|
|
353
371
|
async function runHap(deps2, req, opts) {
|
|
354
372
|
const pathError = packagePathError(req.packagePath);
|
|
355
373
|
if (pathError !== void 0) return { stdout: "", stderr: `${pathError}
|
|
@@ -689,6 +707,7 @@ import {
|
|
|
689
707
|
renderReportJson,
|
|
690
708
|
renderReportXlsx,
|
|
691
709
|
renderSummaryJson,
|
|
710
|
+
renderBundle,
|
|
692
711
|
renderTrendHtml,
|
|
693
712
|
renderTrendJson,
|
|
694
713
|
trendRunFromReport,
|
|
@@ -1155,6 +1174,38 @@ function realDeps(version = packageVersion(), overrides = {}) {
|
|
|
1155
1174
|
...model.comparison === void 0 ? {} : { comparison: { ...model.comparison.totals } }
|
|
1156
1175
|
};
|
|
1157
1176
|
},
|
|
1177
|
+
async render(req) {
|
|
1178
|
+
const file = req.report.endsWith(".json") ? req.report : join2(req.report, "report.json");
|
|
1179
|
+
let parsed;
|
|
1180
|
+
try {
|
|
1181
|
+
parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
1182
|
+
} catch (err) {
|
|
1183
|
+
throw new OhosPerfError3(
|
|
1184
|
+
`cannot read report ${file}: ${safeMessage(err)}`,
|
|
1185
|
+
{ code: "RENDER_BAD_INPUT", cause: err }
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
const model = parsed;
|
|
1189
|
+
if (!Array.isArray(model.sections) || model.scenario === void 0 || model.totals === void 0) {
|
|
1190
|
+
throw new OhosPerfError3(
|
|
1191
|
+
`${file} is not a report document (no sections, scenario or totals block)`,
|
|
1192
|
+
{ code: "RENDER_BAD_INPUT" }
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
const outDir = resolve(req.outDir);
|
|
1196
|
+
const artifacts = renderBundle({ model });
|
|
1197
|
+
await mkdir(outDir, { recursive: true });
|
|
1198
|
+
for (const [name, content] of artifacts) {
|
|
1199
|
+
await writeFile(join2(outDir, name), content);
|
|
1200
|
+
}
|
|
1201
|
+
return {
|
|
1202
|
+
outDir,
|
|
1203
|
+
files: artifacts.map(([name]) => name),
|
|
1204
|
+
sections: model.sections.length,
|
|
1205
|
+
metrics: model.totals.metrics,
|
|
1206
|
+
evidence: model.totals.evidence
|
|
1207
|
+
};
|
|
1208
|
+
},
|
|
1158
1209
|
async trend(req) {
|
|
1159
1210
|
const runs = req.reports.map((report) => {
|
|
1160
1211
|
const file = report.path.endsWith(".json") ? report.path : join2(report.path, "report.json");
|
|
@@ -1585,6 +1636,9 @@ function buildProgram(deps2, io, opts = {}) {
|
|
|
1585
1636
|
);
|
|
1586
1637
|
}
|
|
1587
1638
|
);
|
|
1639
|
+
program2.command("render").description("re-render a saved report bundle from its report.json, without re-analyzing").argument("<report>", "report.json file or the bundle directory that holds one").requiredOption("--out <dir>", "output directory for the re-rendered artifacts").option("--json", "print the artifact manifest as JSON").action(async (report, opts2) => {
|
|
1640
|
+
io.emit(await runRender(deps2, { report, outDir: opts2.out }, { json: opts2.json }));
|
|
1641
|
+
});
|
|
1588
1642
|
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
1643
|
"--label <label>",
|
|
1590
1644
|
"a run label, repeated once per report in order (default: the report path)",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-perf/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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.17.0",
|
|
40
40
|
"commander": "^12.1.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|