@ohos-perf/core 0.12.0 → 0.13.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.d.ts +1252 -957
- package/dist/index.js +845 -246
- package/package.json +48 -48
package/dist/index.js
CHANGED
|
@@ -440,14 +440,14 @@ var Hdc = class {
|
|
|
440
440
|
const failOnStdout = FAIL_PREFIX.test(result.stdout);
|
|
441
441
|
const failOnStderrOnly = !stdoutOk && FAIL_PREFIX.test(result.stderr);
|
|
442
442
|
if (result.code !== 0 || failOnStdout || failOnStderrOnly || !stdoutOk) {
|
|
443
|
-
let
|
|
443
|
+
let detail11;
|
|
444
444
|
if (result.code !== 0) {
|
|
445
445
|
const context = failDetail(result) || firstLine(result);
|
|
446
|
-
|
|
446
|
+
detail11 = `exit code ${result.code}${context ? ` (${context})` : ""}`;
|
|
447
447
|
} else {
|
|
448
|
-
|
|
448
|
+
detail11 = failDetail(result) || "no success marker in output";
|
|
449
449
|
}
|
|
450
|
-
throw new OhosPerfError(`hdc ${op} failed: ${
|
|
450
|
+
throw new OhosPerfError(`hdc ${op} failed: ${detail11}`, {
|
|
451
451
|
code: `HDC_${op.toUpperCase()}_FAILED`
|
|
452
452
|
});
|
|
453
453
|
}
|
|
@@ -470,13 +470,13 @@ function firstLine(result) {
|
|
|
470
470
|
|
|
471
471
|
// src/device/device.ts
|
|
472
472
|
import {
|
|
473
|
-
existsSync as
|
|
473
|
+
existsSync as existsSync11,
|
|
474
474
|
mkdirSync as mkdirSync7,
|
|
475
475
|
mkdtempSync,
|
|
476
|
-
readFileSync as
|
|
476
|
+
readFileSync as readFileSync8,
|
|
477
477
|
renameSync as renameSync3,
|
|
478
478
|
rmSync as rmSync3,
|
|
479
|
-
statSync as
|
|
479
|
+
statSync as statSync3,
|
|
480
480
|
unlinkSync as unlinkSync6,
|
|
481
481
|
writeFileSync as writeFileSync6
|
|
482
482
|
} from "node:fs";
|
|
@@ -2130,6 +2130,101 @@ ${capture.stderr}`;
|
|
|
2130
2130
|
}
|
|
2131
2131
|
};
|
|
2132
2132
|
|
|
2133
|
+
// src/collectors/jsheap.ts
|
|
2134
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6, statSync as statSync2 } from "node:fs";
|
|
2135
|
+
var DEVICE_SNAPSHOT_DIR = "/data/app/el2/100/base";
|
|
2136
|
+
var DEFAULT_TIMEOUT_MS3 = 3e4;
|
|
2137
|
+
var POLL_MS = 1e3;
|
|
2138
|
+
function assertTimeout3(timeoutMs) {
|
|
2139
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
2140
|
+
throw new OhosPerfError(
|
|
2141
|
+
`timeoutMs must be an integer of at least 1 (got ${String(timeoutMs)})`,
|
|
2142
|
+
{ code: "JSHEAP_BAD_TIMEOUT" }
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function detail8(result) {
|
|
2147
|
+
const lines = `${result.stdout}
|
|
2148
|
+
${result.stderr}`.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
2149
|
+
return lines.length === 0 ? "(no output)" : lines.slice(0, 5).join(" | ");
|
|
2150
|
+
}
|
|
2151
|
+
function findNewestSnapshot(hdc, target, app) {
|
|
2152
|
+
return hdc.shell(
|
|
2153
|
+
target,
|
|
2154
|
+
`find ${DEVICE_SNAPSHOT_DIR}/${app} -maxdepth 6 -name '*.heapsnapshot' -printf "%T@ %p\\n" 2>/dev/null | sort -n | tail -1`
|
|
2155
|
+
).then((result) => {
|
|
2156
|
+
const line = result.stdout.trim();
|
|
2157
|
+
if (line === "") return void 0;
|
|
2158
|
+
const space = line.indexOf(" ");
|
|
2159
|
+
return space === -1 ? line : line.slice(space + 1).trim();
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
function sleep(ms) {
|
|
2163
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
2164
|
+
}
|
|
2165
|
+
var JsheapCollector = class {
|
|
2166
|
+
id = "jsheap";
|
|
2167
|
+
provides = ["js.heap"];
|
|
2168
|
+
async collect(hdc, target, opts, layout) {
|
|
2169
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS3;
|
|
2170
|
+
assertTimeout3(timeoutMs);
|
|
2171
|
+
if (opts.app === "") {
|
|
2172
|
+
throw new OhosPerfError(
|
|
2173
|
+
"a JS heap snapshot needs the app package name to locate its data directory",
|
|
2174
|
+
{ code: "JSHEAP_NO_APP" }
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
const pid = await hdc.shell(target, `pidof ${opts.app}`);
|
|
2178
|
+
const pidText = pid.stdout.trim().split(/\s+/)[0] ?? "";
|
|
2179
|
+
if (pid.code !== 0 || !/^\d+$/.test(pidText)) {
|
|
2180
|
+
throw new OhosPerfError(
|
|
2181
|
+
`${opts.app} is not running, so there is no heap to snapshot (pidof: ${detail8(pid)})`,
|
|
2182
|
+
{ code: "JSHEAP_NO_PID" }
|
|
2183
|
+
);
|
|
2184
|
+
}
|
|
2185
|
+
const dump = await hdc.shell(target, `hidumper --mem-jsheap ${pidText} -T ${pidText}`);
|
|
2186
|
+
if (dump.code !== 0) {
|
|
2187
|
+
throw new OhosPerfError(
|
|
2188
|
+
`hidumper --mem-jsheap ${pidText} failed (exit ${dump.code}: ${detail8(dump)}); the app must be debug-signed or profilerable`,
|
|
2189
|
+
{ code: "JSHEAP_UNSUPPORTED" }
|
|
2190
|
+
);
|
|
2191
|
+
}
|
|
2192
|
+
const deadline = Date.now() + timeoutMs;
|
|
2193
|
+
let devicePath;
|
|
2194
|
+
for (; ; ) {
|
|
2195
|
+
devicePath = await findNewestSnapshot(hdc, target, opts.app);
|
|
2196
|
+
if (devicePath !== void 0) break;
|
|
2197
|
+
if (Date.now() >= deadline) break;
|
|
2198
|
+
await sleep(Math.min(POLL_MS, Math.max(1, deadline - Date.now())));
|
|
2199
|
+
}
|
|
2200
|
+
if (devicePath === void 0) {
|
|
2201
|
+
throw new OhosPerfError(
|
|
2202
|
+
`no .heapsnapshot appeared under ${DEVICE_SNAPSHOT_DIR}/${opts.app} within ${timeoutMs} ms of a successful hidumper; the device may need more time, or the app may refuse to write one`,
|
|
2203
|
+
{ code: "JSHEAP_NO_OUTPUT" }
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
await hdc.recv(target, devicePath, layout.jsheapFile);
|
|
2207
|
+
if (!existsSync7(layout.jsheapFile)) {
|
|
2208
|
+
throw new OhosPerfError(
|
|
2209
|
+
`the heap snapshot transfer wrote nothing at ${layout.jsheapFile}`,
|
|
2210
|
+
{ code: "JSHEAP_NO_OUTPUT" }
|
|
2211
|
+
);
|
|
2212
|
+
}
|
|
2213
|
+
const bytes = statSync2(layout.jsheapFile).size;
|
|
2214
|
+
if (bytes === 0) {
|
|
2215
|
+
throw new OhosPerfError(
|
|
2216
|
+
`the heap snapshot at ${layout.jsheapFile} is empty`,
|
|
2217
|
+
{ code: "JSHEAP_NO_OUTPUT" }
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
return { bytes, devicePath };
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
function readJsheapSnapshot(layout) {
|
|
2224
|
+
if (!existsSync7(layout.jsheapFile)) return void 0;
|
|
2225
|
+
return new Uint8Array(readFileSync6(layout.jsheapFile));
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2133
2228
|
// src/report/evidence.ts
|
|
2134
2229
|
import { createHash } from "node:crypto";
|
|
2135
2230
|
function evidenceId(input, key) {
|
|
@@ -2503,7 +2598,7 @@ function assertText(text) {
|
|
|
2503
2598
|
function quote(text) {
|
|
2504
2599
|
return `'${text.replace(/'/g, "'\\''")}'`;
|
|
2505
2600
|
}
|
|
2506
|
-
function
|
|
2601
|
+
function detail9(result) {
|
|
2507
2602
|
const lines = `${result.stdout}
|
|
2508
2603
|
${result.stderr}`.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
2509
2604
|
if (lines.length === 0) return "(no output)";
|
|
@@ -2557,7 +2652,7 @@ var GestureDriver = class {
|
|
|
2557
2652
|
${result.stderr}`;
|
|
2558
2653
|
if (!combined4.includes(ACCEPTED_MARKER)) {
|
|
2559
2654
|
throw new OhosPerfError(
|
|
2560
|
-
`uitest uiInput ${gesture.action} did not report "${ACCEPTED_MARKER}" (exit ${result.code}: ${
|
|
2655
|
+
`uitest uiInput ${gesture.action} did not report "${ACCEPTED_MARKER}" (exit ${result.code}: ${detail9(result)})`,
|
|
2561
2656
|
{ code: "UITEST_INPUT_FAILED" }
|
|
2562
2657
|
);
|
|
2563
2658
|
}
|
|
@@ -2569,7 +2664,7 @@ ${result.stderr}`;
|
|
|
2569
2664
|
};
|
|
2570
2665
|
|
|
2571
2666
|
// src/ingest/metadata.ts
|
|
2572
|
-
import { existsSync as
|
|
2667
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
2573
2668
|
function isRecord4(value) {
|
|
2574
2669
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2575
2670
|
}
|
|
@@ -2606,10 +2701,10 @@ function writeSceneMetadata(layout, meta) {
|
|
|
2606
2701
|
`);
|
|
2607
2702
|
}
|
|
2608
2703
|
function readSceneMetadata(layout) {
|
|
2609
|
-
if (!
|
|
2704
|
+
if (!existsSync8(layout.metadataFile)) return void 0;
|
|
2610
2705
|
let parsed;
|
|
2611
2706
|
try {
|
|
2612
|
-
parsed = JSON.parse(
|
|
2707
|
+
parsed = JSON.parse(readFileSync7(layout.metadataFile, "utf8"));
|
|
2613
2708
|
} catch {
|
|
2614
2709
|
return void 0;
|
|
2615
2710
|
}
|
|
@@ -2664,7 +2759,7 @@ function readSceneMetadata(layout) {
|
|
|
2664
2759
|
}
|
|
2665
2760
|
|
|
2666
2761
|
// src/ingest/scene.ts
|
|
2667
|
-
import { existsSync as
|
|
2762
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync6 } from "node:fs";
|
|
2668
2763
|
import { join as join3 } from "node:path";
|
|
2669
2764
|
|
|
2670
2765
|
// src/db/sqlite.ts
|
|
@@ -2741,6 +2836,8 @@ function createSceneLayout(root) {
|
|
|
2741
2836
|
screenshotFile: join3(root, "screenshot.png"),
|
|
2742
2837
|
hilogFile: join3(root, "hilog.log"),
|
|
2743
2838
|
hilogJsonlFile: join3(root, "hilog.jsonl"),
|
|
2839
|
+
redundantFile: join3(root, "redundant_file.txt"),
|
|
2840
|
+
jsheapFile: join3(root, "jsheap.heapsnapshot"),
|
|
2744
2841
|
metadataFile: join3(root, "scene.json")
|
|
2745
2842
|
};
|
|
2746
2843
|
}
|
|
@@ -2763,8 +2860,8 @@ var Scene = class {
|
|
|
2763
2860
|
}
|
|
2764
2861
|
};
|
|
2765
2862
|
async function ingestScene(streamer, layout) {
|
|
2766
|
-
if (!
|
|
2767
|
-
if (!
|
|
2863
|
+
if (!existsSync9(layout.traceDb)) {
|
|
2864
|
+
if (!existsSync9(layout.traceFile)) {
|
|
2768
2865
|
throw new IngestError(
|
|
2769
2866
|
`Nothing to ingest: trace file not found at ${layout.traceFile} (and no converted database at ${layout.traceDb})`,
|
|
2770
2867
|
"",
|
|
@@ -2779,8 +2876,8 @@ async function ingestScene(streamer, layout) {
|
|
|
2779
2876
|
}
|
|
2780
2877
|
async function openPerfDb(streamer, layout) {
|
|
2781
2878
|
if (layout.perfDb === void 0) return void 0;
|
|
2782
|
-
if (!
|
|
2783
|
-
if (layout.perfFile === void 0 || !
|
|
2879
|
+
if (!existsSync9(layout.perfDb)) {
|
|
2880
|
+
if (layout.perfFile === void 0 || !existsSync9(layout.perfFile)) return void 0;
|
|
2784
2881
|
mkdirSync6(layout.root, { recursive: true });
|
|
2785
2882
|
await streamer.convert(layout.perfFile, layout.perfDb);
|
|
2786
2883
|
}
|
|
@@ -2789,7 +2886,7 @@ async function openPerfDb(streamer, layout) {
|
|
|
2789
2886
|
|
|
2790
2887
|
// src/ingest/streamer.ts
|
|
2791
2888
|
import { spawn as spawn2 } from "node:child_process";
|
|
2792
|
-
import { existsSync as
|
|
2889
|
+
import { existsSync as existsSync10, renameSync as renameSync2, rmSync as rmSync2 } from "node:fs";
|
|
2793
2890
|
import { delimiter as delimiter2, join as join4 } from "node:path";
|
|
2794
2891
|
var MIN_VERSION = [4, 3, 0];
|
|
2795
2892
|
var SIDECAR_SUFFIX = ".ohos.ts";
|
|
@@ -2909,7 +3006,7 @@ var Streamer = class {
|
|
|
2909
3006
|
`STREAMER_EXIT_${result.code}`
|
|
2910
3007
|
);
|
|
2911
3008
|
}
|
|
2912
|
-
if (!
|
|
3009
|
+
if (!existsSync10(tempPath)) {
|
|
2913
3010
|
throw new IngestError(
|
|
2914
3011
|
`trace_streamer exited 0 but produced no database for ${inputPath}`,
|
|
2915
3012
|
result.stderr,
|
|
@@ -2928,7 +3025,7 @@ var Streamer = class {
|
|
|
2928
3025
|
}
|
|
2929
3026
|
committed = true;
|
|
2930
3027
|
try {
|
|
2931
|
-
if (
|
|
3028
|
+
if (existsSync10(tempSidecar)) renameSync2(tempSidecar, outputDbPath + SIDECAR_SUFFIX);
|
|
2932
3029
|
} catch {
|
|
2933
3030
|
}
|
|
2934
3031
|
} finally {
|
|
@@ -2992,7 +3089,7 @@ var Streamer = class {
|
|
|
2992
3089
|
if (dir) push(join4(dir, bin));
|
|
2993
3090
|
}
|
|
2994
3091
|
for (const candidate of candidates) {
|
|
2995
|
-
if (
|
|
3092
|
+
if (existsSync10(candidate)) {
|
|
2996
3093
|
this.resolvedPath = candidate;
|
|
2997
3094
|
return candidate;
|
|
2998
3095
|
}
|
|
@@ -3311,6 +3408,7 @@ var Device = class {
|
|
|
3311
3408
|
const wantsUitest = opts.uitest === true;
|
|
3312
3409
|
const wantsScreenshot = opts.screenshot === true;
|
|
3313
3410
|
const wantsHilog = opts.hilog === true;
|
|
3411
|
+
const wantsJsheap = opts.jsheap === true;
|
|
3314
3412
|
const hiperfApp = wantsHiperf ? requireApp("hiperf", " to profile") : void 0;
|
|
3315
3413
|
if (hiperfApp !== void 0 && !BARE_NAME.test(hiperfApp)) {
|
|
3316
3414
|
throw new OhosPerfError(
|
|
@@ -3326,7 +3424,7 @@ var Device = class {
|
|
|
3326
3424
|
mkdirSync7(layout.root, { recursive: true });
|
|
3327
3425
|
const previous = /* @__PURE__ */ new Map();
|
|
3328
3426
|
const remember = (path) => {
|
|
3329
|
-
previous.set(path,
|
|
3427
|
+
previous.set(path, existsSync11(path) ? readFileSync8(path) : void 0);
|
|
3330
3428
|
};
|
|
3331
3429
|
if (wantsProcfs) remember(layout.procfsFile);
|
|
3332
3430
|
if (wantsHiperf) {
|
|
@@ -3336,6 +3434,7 @@ var Device = class {
|
|
|
3336
3434
|
if (wantsHidumper) remember(layout.hidumperFile);
|
|
3337
3435
|
if (wantsUitest) remember(layout.uiFile);
|
|
3338
3436
|
if (wantsScreenshot) remember(layout.screenshotFile);
|
|
3437
|
+
if (wantsJsheap) remember(layout.jsheapFile);
|
|
3339
3438
|
if (wantsHilog) {
|
|
3340
3439
|
remember(layout.hilogFile);
|
|
3341
3440
|
remember(layout.hilogJsonlFile);
|
|
@@ -3404,6 +3503,7 @@ var Device = class {
|
|
|
3404
3503
|
let uiNodes;
|
|
3405
3504
|
let screenshotCapture;
|
|
3406
3505
|
let hilogLines;
|
|
3506
|
+
let jsheapCapture;
|
|
3407
3507
|
try {
|
|
3408
3508
|
const runs = [runTrace()];
|
|
3409
3509
|
if (wantsProcfs) {
|
|
@@ -3447,6 +3547,12 @@ var Device = class {
|
|
|
3447
3547
|
const hilog = this.deps.hilog ?? new HilogCollector();
|
|
3448
3548
|
runs.push(hilog.collect(hdc, this.id, { durationMs: opts.durationMs }, layout));
|
|
3449
3549
|
}
|
|
3550
|
+
if (wantsJsheap) {
|
|
3551
|
+
const jsheap = this.deps.jsheap ?? new JsheapCollector();
|
|
3552
|
+
runs.push(
|
|
3553
|
+
jsheap.collect(hdc, this.id, { app: opts.app ?? "" }, layout)
|
|
3554
|
+
);
|
|
3555
|
+
}
|
|
3450
3556
|
let firstFailure;
|
|
3451
3557
|
const guarded = runs.map((run) => run.catch((error) => {
|
|
3452
3558
|
firstFailure ??= { error };
|
|
@@ -3463,7 +3569,8 @@ var Device = class {
|
|
|
3463
3569
|
if (wantsHidumper) hidumperCapture = results[index++];
|
|
3464
3570
|
if (wantsUitest) uiNodes = results[index++];
|
|
3465
3571
|
if (wantsScreenshot) screenshotCapture = results[index++];
|
|
3466
|
-
if (wantsHilog) hilogLines = results[index].lines;
|
|
3572
|
+
if (wantsHilog) hilogLines = results[index++].lines;
|
|
3573
|
+
if (wantsJsheap) jsheapCapture = results[index++];
|
|
3467
3574
|
} catch (err) {
|
|
3468
3575
|
restoreArtifacts(previous);
|
|
3469
3576
|
throw err;
|
|
@@ -3561,14 +3668,14 @@ function removeIfPresent(path) {
|
|
|
3561
3668
|
}
|
|
3562
3669
|
function isDirectorySync(path) {
|
|
3563
3670
|
try {
|
|
3564
|
-
return
|
|
3671
|
+
return statSync3(path).isDirectory();
|
|
3565
3672
|
} catch {
|
|
3566
3673
|
return false;
|
|
3567
3674
|
}
|
|
3568
3675
|
}
|
|
3569
3676
|
var previousSuffix = ".previous-ohosperf";
|
|
3570
3677
|
function setAside(path, suffix) {
|
|
3571
|
-
if (!
|
|
3678
|
+
if (!existsSync11(path)) return void 0;
|
|
3572
3679
|
const parked = `${path}${suffix}`;
|
|
3573
3680
|
rmSync3(parked, { force: true });
|
|
3574
3681
|
renameSync3(path, parked);
|
|
@@ -3651,7 +3758,7 @@ async function connect(opts = {}) {
|
|
|
3651
3758
|
|
|
3652
3759
|
// src/device/emulator.ts
|
|
3653
3760
|
import { spawn as spawn3 } from "node:child_process";
|
|
3654
|
-
import { existsSync as
|
|
3761
|
+
import { existsSync as existsSync12, readdirSync as readdirSync2, readFileSync as readFileSync9 } from "node:fs";
|
|
3655
3762
|
import { delimiter as delimiter3, join as join6 } from "node:path";
|
|
3656
3763
|
var FAILURE_LINE = /^(?:Emulator: |Unable to )/;
|
|
3657
3764
|
var START_SETTLE_MS = 3e3;
|
|
@@ -3693,7 +3800,7 @@ function readEmuConfigRoots(env, platform) {
|
|
|
3693
3800
|
for (const dir of dirs) {
|
|
3694
3801
|
let text;
|
|
3695
3802
|
try {
|
|
3696
|
-
text =
|
|
3803
|
+
text = readFileSync9(join6(huawei, dir, ".emu_config"), "utf8");
|
|
3697
3804
|
} catch {
|
|
3698
3805
|
continue;
|
|
3699
3806
|
}
|
|
@@ -3772,7 +3879,7 @@ var EmulatorClient = class {
|
|
|
3772
3879
|
if (dir) push(join6(dir, bin));
|
|
3773
3880
|
}
|
|
3774
3881
|
for (const candidate of candidates) {
|
|
3775
|
-
if (
|
|
3882
|
+
if (existsSync12(candidate)) {
|
|
3776
3883
|
this.resolvedPath = candidate;
|
|
3777
3884
|
return candidate;
|
|
3778
3885
|
}
|
|
@@ -3999,9 +4106,9 @@ ${result.stderr}`;
|
|
|
3999
4106
|
throw new EmulatorCommandError(failure, output, { code: "EMULATOR_COMMAND_FAILED" });
|
|
4000
4107
|
}
|
|
4001
4108
|
if (result.code !== 0) {
|
|
4002
|
-
const
|
|
4109
|
+
const detail11 = lines.length === 0 ? "" : `: ${lines[0]}`;
|
|
4003
4110
|
throw new EmulatorCommandError(
|
|
4004
|
-
`${args[0] ?? "emulator"} exited ${result.code}${
|
|
4111
|
+
`${args[0] ?? "emulator"} exited ${result.code}${detail11}`,
|
|
4005
4112
|
output,
|
|
4006
4113
|
{ code: "EMULATOR_COMMAND_FAILED" }
|
|
4007
4114
|
);
|
|
@@ -4039,7 +4146,7 @@ function stringField(row2, key) {
|
|
|
4039
4146
|
function optional(key, value) {
|
|
4040
4147
|
return value === void 0 || value === "" ? {} : { [key]: value };
|
|
4041
4148
|
}
|
|
4042
|
-
function
|
|
4149
|
+
function sleep2(ms) {
|
|
4043
4150
|
return new Promise((resolve2) => {
|
|
4044
4151
|
setTimeout(resolve2, ms);
|
|
4045
4152
|
});
|
|
@@ -4262,7 +4369,7 @@ var EmulatorLifecycle = class {
|
|
|
4262
4369
|
}
|
|
4263
4370
|
const value = await attempt();
|
|
4264
4371
|
if (value !== void 0) return value;
|
|
4265
|
-
await
|
|
4372
|
+
await sleep2(this.pollMs);
|
|
4266
4373
|
}
|
|
4267
4374
|
}
|
|
4268
4375
|
};
|
|
@@ -4898,7 +5005,7 @@ function diffTrees(before, after) {
|
|
|
4898
5005
|
}
|
|
4899
5006
|
|
|
4900
5007
|
// src/ui/compare.ts
|
|
4901
|
-
import { existsSync as
|
|
5008
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
4902
5009
|
import { join as join7, resolve } from "node:path";
|
|
4903
5010
|
|
|
4904
5011
|
// src/report/escape.ts
|
|
@@ -5049,7 +5156,7 @@ function missing(side, artifact, dir) {
|
|
|
5049
5156
|
}
|
|
5050
5157
|
function readImage(path) {
|
|
5051
5158
|
try {
|
|
5052
|
-
return decodePng(new Uint8Array(
|
|
5159
|
+
return decodePng(new Uint8Array(readFileSync10(path)));
|
|
5053
5160
|
} catch (err) {
|
|
5054
5161
|
throw new OhosPerfError(
|
|
5055
5162
|
`${path} is not a readable PNG: ${err.message}`,
|
|
@@ -5077,8 +5184,8 @@ function collectRegions(tree) {
|
|
|
5077
5184
|
}
|
|
5078
5185
|
function readSide(dir, side) {
|
|
5079
5186
|
const layout = createSceneLayout(dir);
|
|
5080
|
-
const hasImage =
|
|
5081
|
-
const hasTree =
|
|
5187
|
+
const hasImage = existsSync13(layout.screenshotFile);
|
|
5188
|
+
const hasTree = existsSync13(layout.uiFile);
|
|
5082
5189
|
return {
|
|
5083
5190
|
image: hasImage ? readImage(layout.screenshotFile) : void 0,
|
|
5084
5191
|
nodes: hasTree ? readUiTree(layout.uiFile, { full: true }) : void 0
|
|
@@ -5816,13 +5923,13 @@ function parseScenario(text) {
|
|
|
5816
5923
|
}
|
|
5817
5924
|
|
|
5818
5925
|
// src/scenario/cases.ts
|
|
5819
|
-
import { readFileSync as
|
|
5926
|
+
import { readFileSync as readFileSync11, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
5820
5927
|
import { basename, join as join8 } from "node:path";
|
|
5821
5928
|
var CASE_SUFFIX = ".scenario.json";
|
|
5822
5929
|
function discoverCases(dir, filter) {
|
|
5823
5930
|
let entries;
|
|
5824
5931
|
try {
|
|
5825
|
-
if (!
|
|
5932
|
+
if (!statSync4(dir).isDirectory()) {
|
|
5826
5933
|
throw new Error("not a directory");
|
|
5827
5934
|
}
|
|
5828
5935
|
entries = readdirSync3(dir);
|
|
@@ -5852,48 +5959,648 @@ function discoverCases(dir, filter) {
|
|
|
5852
5959
|
{ code: "SCENARIO_BAD_INPUT", cause: err }
|
|
5853
5960
|
);
|
|
5854
5961
|
}
|
|
5855
|
-
const matched = found.filter((entry) => pattern.test(entry.id));
|
|
5856
|
-
if (matched.length === 0) {
|
|
5857
|
-
throw new OhosPerfError(
|
|
5858
|
-
`--filter ${JSON.stringify(filter)} matched no case; the directory has ${found.map((entry) => entry.id).join(", ")}`,
|
|
5859
|
-
{ code: "SCENARIO_CASES_EMPTY" }
|
|
5860
|
-
);
|
|
5962
|
+
const matched = found.filter((entry) => pattern.test(entry.id));
|
|
5963
|
+
if (matched.length === 0) {
|
|
5964
|
+
throw new OhosPerfError(
|
|
5965
|
+
`--filter ${JSON.stringify(filter)} matched no case; the directory has ${found.map((entry) => entry.id).join(", ")}`,
|
|
5966
|
+
{ code: "SCENARIO_CASES_EMPTY" }
|
|
5967
|
+
);
|
|
5968
|
+
}
|
|
5969
|
+
return matched;
|
|
5970
|
+
}
|
|
5971
|
+
function loadCases(cases) {
|
|
5972
|
+
return cases.map((entry) => {
|
|
5973
|
+
let text;
|
|
5974
|
+
try {
|
|
5975
|
+
text = readFileSync11(entry.path, "utf8");
|
|
5976
|
+
} catch (err) {
|
|
5977
|
+
return {
|
|
5978
|
+
id: entry.id,
|
|
5979
|
+
path: entry.path,
|
|
5980
|
+
error: `${basename(entry.path)}: cannot be read (${errorCode(err)})`
|
|
5981
|
+
};
|
|
5982
|
+
}
|
|
5983
|
+
try {
|
|
5984
|
+
return { id: entry.id, path: entry.path, scenario: parseScenario(text) };
|
|
5985
|
+
} catch (err) {
|
|
5986
|
+
return { id: entry.id, path: entry.path, error: `${basename(entry.path)}: ${message(err)}` };
|
|
5987
|
+
}
|
|
5988
|
+
});
|
|
5989
|
+
}
|
|
5990
|
+
function message(err) {
|
|
5991
|
+
return err instanceof Error ? err.message : String(err);
|
|
5992
|
+
}
|
|
5993
|
+
function errorCode(err) {
|
|
5994
|
+
const code = err?.code;
|
|
5995
|
+
return typeof code === "string" ? code : "unreadable";
|
|
5996
|
+
}
|
|
5997
|
+
|
|
5998
|
+
// src/parity.ts
|
|
5999
|
+
var PARITY_ROWS = [
|
|
6000
|
+
{
|
|
6001
|
+
row: 1,
|
|
6002
|
+
name: "Scripted performance test execution (`perf`)",
|
|
6003
|
+
status: "ported",
|
|
6004
|
+
reason: ""
|
|
6005
|
+
},
|
|
6006
|
+
{
|
|
6007
|
+
row: 2,
|
|
6008
|
+
name: "Run-only preparation (`prepare`)",
|
|
6009
|
+
status: "ported",
|
|
6010
|
+
reason: ""
|
|
6011
|
+
},
|
|
6012
|
+
{ row: 3, name: "YAML UI test DSL", status: "ported", reason: "" },
|
|
6013
|
+
{
|
|
6014
|
+
row: 4,
|
|
6015
|
+
name: "HapTest autonomous exploration (`haptest`)",
|
|
6016
|
+
status: "out",
|
|
6017
|
+
reason: "HapRay's own implementation is nondeterministic and has no success verification; the agent skill drives selectors and drill-down queries deterministically instead."
|
|
6018
|
+
},
|
|
6019
|
+
{
|
|
6020
|
+
row: 5,
|
|
6021
|
+
name: "LLM GUI agent (`gui-agent`)",
|
|
6022
|
+
status: "out",
|
|
6023
|
+
reason: "Requires a network LLM endpoint and an API key, and never verifies task success; the agent skill is the deterministic replacement."
|
|
6024
|
+
},
|
|
6025
|
+
{
|
|
6026
|
+
row: 6,
|
|
6027
|
+
name: "Per-step capture orchestration",
|
|
6028
|
+
status: "ported",
|
|
6029
|
+
reason: ""
|
|
6030
|
+
},
|
|
6031
|
+
{ row: 7, name: "UI capture per step", status: "ported", reason: "" },
|
|
6032
|
+
{
|
|
6033
|
+
row: 8,
|
|
6034
|
+
name: "Frame stutter / FPS analysis",
|
|
6035
|
+
status: "ported",
|
|
6036
|
+
reason: "",
|
|
6037
|
+
analyzer: "FrameAnalyzer"
|
|
6038
|
+
},
|
|
6039
|
+
{
|
|
6040
|
+
row: 9,
|
|
6041
|
+
name: "Frame load / instruction attribution",
|
|
6042
|
+
status: "ported",
|
|
6043
|
+
reason: "",
|
|
6044
|
+
analyzer: "FrameLoadAnalyzer"
|
|
6045
|
+
},
|
|
6046
|
+
{
|
|
6047
|
+
row: 10,
|
|
6048
|
+
name: "Empty-frame analysis",
|
|
6049
|
+
status: "ported",
|
|
6050
|
+
reason: "",
|
|
6051
|
+
analyzer: "EmptyFrameAnalyzer"
|
|
6052
|
+
},
|
|
6053
|
+
{
|
|
6054
|
+
row: 11,
|
|
6055
|
+
name: "VSync anomaly",
|
|
6056
|
+
status: "ported",
|
|
6057
|
+
reason: "",
|
|
6058
|
+
analyzer: "VsyncAnalyzer"
|
|
6059
|
+
},
|
|
6060
|
+
{
|
|
6061
|
+
row: 12,
|
|
6062
|
+
name: "RenderService skip reverse tracing",
|
|
6063
|
+
status: "partial",
|
|
6064
|
+
reason: "Missing the system-API `UnMarsh RSTransactionData` backtracking and the CPU-waste metric; the NativeWindow path and per-frame evidence are ported.",
|
|
6065
|
+
analyzer: "RsSkipAnalyzer"
|
|
6066
|
+
},
|
|
6067
|
+
{
|
|
6068
|
+
row: 13,
|
|
6069
|
+
name: "IPC binder analysis",
|
|
6070
|
+
status: "ported",
|
|
6071
|
+
reason: "",
|
|
6072
|
+
analyzer: "BinderAnalyzer"
|
|
6073
|
+
},
|
|
6074
|
+
{
|
|
6075
|
+
row: 14,
|
|
6076
|
+
name: "Fault tree core sections",
|
|
6077
|
+
status: "ported",
|
|
6078
|
+
reason: "",
|
|
6079
|
+
analyzer: "FaultTreeAnalyzer"
|
|
6080
|
+
},
|
|
6081
|
+
{
|
|
6082
|
+
row: 15,
|
|
6083
|
+
name: "Fault tree `ipc_binder` section",
|
|
6084
|
+
status: "ported",
|
|
6085
|
+
reason: "",
|
|
6086
|
+
analyzer: "FaultTreeAnalyzer"
|
|
6087
|
+
},
|
|
6088
|
+
{
|
|
6089
|
+
row: 16,
|
|
6090
|
+
name: "GC pressure",
|
|
6091
|
+
status: "ported",
|
|
6092
|
+
reason: "",
|
|
6093
|
+
analyzer: "GcAnalyzer"
|
|
6094
|
+
},
|
|
6095
|
+
{
|
|
6096
|
+
row: 17,
|
|
6097
|
+
name: "Component reuse",
|
|
6098
|
+
status: "ported",
|
|
6099
|
+
reason: "",
|
|
6100
|
+
analyzer: "ComponentReuseAnalyzer"
|
|
6101
|
+
},
|
|
6102
|
+
{
|
|
6103
|
+
row: 18,
|
|
6104
|
+
name: "Thread wakeup chain",
|
|
6105
|
+
status: "ported",
|
|
6106
|
+
reason: "",
|
|
6107
|
+
analyzer: "ThreadAnalyzer"
|
|
6108
|
+
},
|
|
6109
|
+
{
|
|
6110
|
+
row: 19,
|
|
6111
|
+
name: "Native memory analysis",
|
|
6112
|
+
status: "ported",
|
|
6113
|
+
reason: "",
|
|
6114
|
+
analyzer: "NativeMemoryAnalyzer"
|
|
6115
|
+
},
|
|
6116
|
+
{
|
|
6117
|
+
row: 20,
|
|
6118
|
+
name: "JS heap snapshot capture",
|
|
6119
|
+
status: "ported",
|
|
6120
|
+
reason: ""
|
|
6121
|
+
},
|
|
6122
|
+
{
|
|
6123
|
+
row: 21,
|
|
6124
|
+
name: "Cold start redundant-file I/O",
|
|
6125
|
+
status: "ported",
|
|
6126
|
+
reason: "",
|
|
6127
|
+
analyzer: "RedundantFileAnalyzer"
|
|
6128
|
+
},
|
|
6129
|
+
{
|
|
6130
|
+
row: 22,
|
|
6131
|
+
name: "Flamegraph generation",
|
|
6132
|
+
status: "ported",
|
|
6133
|
+
reason: "",
|
|
6134
|
+
analyzer: "FlamegraphAnalyzer"
|
|
6135
|
+
},
|
|
6136
|
+
{
|
|
6137
|
+
row: 23,
|
|
6138
|
+
name: "Symbol statistics",
|
|
6139
|
+
status: "ported",
|
|
6140
|
+
reason: "",
|
|
6141
|
+
analyzer: "SymbolsAnalyzer"
|
|
6142
|
+
},
|
|
6143
|
+
{
|
|
6144
|
+
row: 24,
|
|
6145
|
+
name: "Coverage",
|
|
6146
|
+
status: "out",
|
|
6147
|
+
reason: "Needs an instrumented build and the external `bjc` toolchain; the capability reports the measured `bjc_cov` probe result instead of a silent zero."
|
|
6148
|
+
},
|
|
6149
|
+
{
|
|
6150
|
+
row: 25,
|
|
6151
|
+
name: "Static HAP tech-stack analysis",
|
|
6152
|
+
status: "ported",
|
|
6153
|
+
reason: ""
|
|
6154
|
+
},
|
|
6155
|
+
{ row: 26, name: "HAP size analysis", status: "ported", reason: "" },
|
|
6156
|
+
{
|
|
6157
|
+
row: 27,
|
|
6158
|
+
name: "Optimization detector (`opt-detector`)",
|
|
6159
|
+
status: "out",
|
|
6160
|
+
reason: "Requires a ~2 GB TensorFlow LSTM plus an sklearn classifier and is AArch64-only; it is a probabilistic guess, not a measurement."
|
|
6161
|
+
},
|
|
6162
|
+
{
|
|
6163
|
+
row: 28,
|
|
6164
|
+
name: "Symbol recovery",
|
|
6165
|
+
status: "out",
|
|
6166
|
+
reason: "Heuristic disassembly (radare2/capstone) plus LLM naming, with no accuracy measurement; device `--so-dir` symbolization covers the resolved symbols."
|
|
6167
|
+
},
|
|
6168
|
+
{
|
|
6169
|
+
row: 29,
|
|
6170
|
+
name: "HapFlow static/dynamic integration",
|
|
6171
|
+
status: "ported",
|
|
6172
|
+
reason: ""
|
|
6173
|
+
},
|
|
6174
|
+
{
|
|
6175
|
+
row: 30,
|
|
6176
|
+
name: "Hilog analysis",
|
|
6177
|
+
status: "ported",
|
|
6178
|
+
reason: "",
|
|
6179
|
+
analyzer: "HilogAnalyzer"
|
|
6180
|
+
},
|
|
6181
|
+
{
|
|
6182
|
+
row: 31,
|
|
6183
|
+
name: "UI animation analysis",
|
|
6184
|
+
status: "partial",
|
|
6185
|
+
reason: "A start/end capture pair is compared by the same tree and image comparators, but the animation label itself is not emitted: dHash thresholds are unvalidated and resolution dependent.",
|
|
6186
|
+
analyzer: "UiAnalyzer"
|
|
6187
|
+
},
|
|
6188
|
+
{
|
|
6189
|
+
row: 32,
|
|
6190
|
+
name: "UI comparison (`ui-compare`)",
|
|
6191
|
+
status: "ported",
|
|
6192
|
+
reason: ""
|
|
6193
|
+
},
|
|
6194
|
+
{
|
|
6195
|
+
row: 33,
|
|
6196
|
+
name: "Report bundle, dashboard and update",
|
|
6197
|
+
status: "partial",
|
|
6198
|
+
reason: "The typed report model, offline HTML, JSON/CSV/XLSX and baseline comparison are ported; the multi-version trend page and re-render-from-saved-inputs are not."
|
|
6199
|
+
},
|
|
6200
|
+
{
|
|
6201
|
+
row: 34,
|
|
6202
|
+
name: "XLSX report suite",
|
|
6203
|
+
status: "ported",
|
|
6204
|
+
reason: ""
|
|
6205
|
+
},
|
|
6206
|
+
{
|
|
6207
|
+
row: 35,
|
|
6208
|
+
name: "Report comparison",
|
|
6209
|
+
status: "partial",
|
|
6210
|
+
reason: "Typed comparison and the scene+step pivot are ported; aggregating more than two reports into one trend is not."
|
|
6211
|
+
}
|
|
6212
|
+
];
|
|
6213
|
+
function paritySummary() {
|
|
6214
|
+
let ported = 0;
|
|
6215
|
+
let partial = 0;
|
|
6216
|
+
let missing2 = 0;
|
|
6217
|
+
let out = 0;
|
|
6218
|
+
for (const row2 of PARITY_ROWS) {
|
|
6219
|
+
if (row2.status === "ported") ported += 1;
|
|
6220
|
+
else if (row2.status === "partial") partial += 1;
|
|
6221
|
+
else if (row2.status === "missing") missing2 += 1;
|
|
6222
|
+
else out += 1;
|
|
6223
|
+
}
|
|
6224
|
+
return { ported, partial, missing: missing2, out, total: PARITY_ROWS.length };
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6227
|
+
// src/analyze/redundant-file.ts
|
|
6228
|
+
function parseRedundantFile(text) {
|
|
6229
|
+
const byPath2 = /* @__PURE__ */ new Map();
|
|
6230
|
+
let reads = 0;
|
|
6231
|
+
const lines = text.split(/\r?\n/);
|
|
6232
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
6233
|
+
const line = lines[index].trim();
|
|
6234
|
+
if (line === "" || line.startsWith("#")) continue;
|
|
6235
|
+
const parts = line.split(/\s+/);
|
|
6236
|
+
const path = parts[0];
|
|
6237
|
+
const marker = parts[1];
|
|
6238
|
+
if (parts.length > 2 || marker !== void 0 && marker !== "USED" && marker !== "UNUSED") {
|
|
6239
|
+
throw new OhosPerfError(
|
|
6240
|
+
`redundant_file.txt line ${index + 1}: expected "<path> [USED|UNUSED]", got ${JSON.stringify(line)}`,
|
|
6241
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
6242
|
+
);
|
|
6243
|
+
}
|
|
6244
|
+
reads += 1;
|
|
6245
|
+
const used = marker !== "UNUSED";
|
|
6246
|
+
const existing = byPath2.get(path);
|
|
6247
|
+
if (existing === void 0) {
|
|
6248
|
+
byPath2.set(path, { reads: 1, used });
|
|
6249
|
+
} else {
|
|
6250
|
+
existing.reads += 1;
|
|
6251
|
+
existing.used = existing.used || used;
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
const files = [...byPath2.entries()].map(([path, value]) => ({ path, reads: value.reads, used: value.used })).sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
6255
|
+
return {
|
|
6256
|
+
reads,
|
|
6257
|
+
files,
|
|
6258
|
+
used: files.filter((file) => file.used).length,
|
|
6259
|
+
unused: files.filter((file) => !file.used).length
|
|
6260
|
+
};
|
|
6261
|
+
}
|
|
6262
|
+
var RedundantFileAnalyzer = class {
|
|
6263
|
+
id = "redundant-file";
|
|
6264
|
+
requires = [];
|
|
6265
|
+
async run(ctx) {
|
|
6266
|
+
const text = ctx.redundantFile;
|
|
6267
|
+
if (text === void 0) {
|
|
6268
|
+
return {
|
|
6269
|
+
metrics: [],
|
|
6270
|
+
evidence: [
|
|
6271
|
+
evidence({
|
|
6272
|
+
kind: "no_data",
|
|
6273
|
+
severity: "info",
|
|
6274
|
+
subject: { process: ctx.app.packageName },
|
|
6275
|
+
window: ctx.window,
|
|
6276
|
+
signals: {},
|
|
6277
|
+
explain: "the scene carries no redundant_file.txt; cold-start redundant-file I/O was not measured",
|
|
6278
|
+
drillDown: [],
|
|
6279
|
+
key: "redundant-file:no-file"
|
|
6280
|
+
})
|
|
6281
|
+
]
|
|
6282
|
+
};
|
|
6283
|
+
}
|
|
6284
|
+
const report = parseRedundantFile(text);
|
|
6285
|
+
const make = (id, value) => metric({
|
|
6286
|
+
id,
|
|
6287
|
+
value,
|
|
6288
|
+
unit: "count",
|
|
6289
|
+
fidelity: "exact",
|
|
6290
|
+
provenance: {
|
|
6291
|
+
collector: "scene:redundant_file.txt",
|
|
6292
|
+
table: "redundant_file",
|
|
6293
|
+
rows: report.reads,
|
|
6294
|
+
device: ctx.deviceId
|
|
6295
|
+
}
|
|
6296
|
+
});
|
|
6297
|
+
return {
|
|
6298
|
+
metrics: [
|
|
6299
|
+
make("redundant_file.reads.count", report.reads),
|
|
6300
|
+
make("redundant_file.files.used", report.used),
|
|
6301
|
+
make("redundant_file.files.unused", report.unused)
|
|
6302
|
+
],
|
|
6303
|
+
evidence: report.files.filter((file) => !file.used).slice(0, 10).map(
|
|
6304
|
+
(file) => evidence({
|
|
6305
|
+
kind: "redundant_file",
|
|
6306
|
+
severity: "info",
|
|
6307
|
+
subject: { process: ctx.app.packageName },
|
|
6308
|
+
window: ctx.window,
|
|
6309
|
+
signals: { path: file.path, reads: file.reads },
|
|
6310
|
+
explain: `${file.path}: read ${file.reads} time(s), never used`,
|
|
6311
|
+
drillDown: [],
|
|
6312
|
+
key: file.path
|
|
6313
|
+
})
|
|
6314
|
+
)
|
|
6315
|
+
};
|
|
6316
|
+
}
|
|
6317
|
+
};
|
|
6318
|
+
|
|
6319
|
+
// src/hap/depgraph.ts
|
|
6320
|
+
function segments(path) {
|
|
6321
|
+
return path.split(/[\\/]/).filter((part) => part !== "" && part !== ".");
|
|
6322
|
+
}
|
|
6323
|
+
function underSegments(path, prefix) {
|
|
6324
|
+
if (prefix.length === 0 || prefix.length > path.length) return false;
|
|
6325
|
+
for (let index = 0; index < prefix.length; index += 1) {
|
|
6326
|
+
if (path[index] !== prefix[index]) return false;
|
|
6327
|
+
}
|
|
6328
|
+
return true;
|
|
6329
|
+
}
|
|
6330
|
+
function compare(a, b) {
|
|
6331
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
6332
|
+
}
|
|
6333
|
+
function buildDepGraph(files, modules, edges = [], durationsMs = {}) {
|
|
6334
|
+
const moduleSegments = modules.map((module) => ({
|
|
6335
|
+
name: module.name,
|
|
6336
|
+
segments: segments(module.path)
|
|
6337
|
+
}));
|
|
6338
|
+
const owner = (path) => {
|
|
6339
|
+
const parts = segments(path);
|
|
6340
|
+
let best;
|
|
6341
|
+
for (const module of moduleSegments) {
|
|
6342
|
+
if (!underSegments(parts, module.segments)) continue;
|
|
6343
|
+
if (best === void 0 || module.segments.length > best.length) {
|
|
6344
|
+
best = { name: module.name, length: module.segments.length };
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6347
|
+
return best?.name;
|
|
6348
|
+
};
|
|
6349
|
+
const graphFiles = [...files].sort(compare).map((path) => {
|
|
6350
|
+
const module = owner(path);
|
|
6351
|
+
return module === void 0 ? { path } : { path, module };
|
|
6352
|
+
});
|
|
6353
|
+
const ownerOf = new Map(graphFiles.map((file) => [file.path, file.module]));
|
|
6354
|
+
const graphEdges = [...edges].map((edge) => ({ from: edge.from, to: edge.to })).sort((a, b) => compare(a.from, b.from) || compare(a.to, b.to));
|
|
6355
|
+
const counts = /* @__PURE__ */ new Map();
|
|
6356
|
+
for (const edge of graphEdges) {
|
|
6357
|
+
const from = ownerOf.get(edge.from);
|
|
6358
|
+
const to = ownerOf.get(edge.to);
|
|
6359
|
+
if (from === void 0 || to === void 0 || from === to) continue;
|
|
6360
|
+
const key = `${from}\0${to}`;
|
|
6361
|
+
const existing = counts.get(key);
|
|
6362
|
+
if (existing === void 0) counts.set(key, { from, to, count: 1 });
|
|
6363
|
+
else counts.set(key, { from, to, count: existing.count + 1 });
|
|
6364
|
+
}
|
|
6365
|
+
const harEdges = [...counts.values()].sort(
|
|
6366
|
+
(a, b) => compare(a.from, b.from) || compare(a.to, b.to)
|
|
6367
|
+
);
|
|
6368
|
+
const timingCycles = computeTimingCycles(harEdges, durationsMs);
|
|
6369
|
+
return { files: graphFiles, edges: graphEdges, harEdges, timingCycles };
|
|
6370
|
+
}
|
|
6371
|
+
function computeTimingCycles(harEdges, durationsMs) {
|
|
6372
|
+
const modules = Object.keys(durationsMs);
|
|
6373
|
+
if (modules.length === 0) return [];
|
|
6374
|
+
const cycles = [];
|
|
6375
|
+
for (const edge of harEdges) {
|
|
6376
|
+
const from = durationsMs[edge.from];
|
|
6377
|
+
const to = durationsMs[edge.to];
|
|
6378
|
+
if (from === void 0 || to === void 0) continue;
|
|
6379
|
+
cycles.push({ modules: [edge.from, edge.to], ms: from + to });
|
|
6380
|
+
}
|
|
6381
|
+
return cycles;
|
|
6382
|
+
}
|
|
6383
|
+
|
|
6384
|
+
// src/report/compare.ts
|
|
6385
|
+
var METRIC_DIRECTIONS = {
|
|
6386
|
+
"frame.avg.duration": "lower",
|
|
6387
|
+
"frame.count": "higher",
|
|
6388
|
+
"frame.empty.rate": "lower",
|
|
6389
|
+
"frame.fps": "higher",
|
|
6390
|
+
"frame.jank.rate": "lower",
|
|
6391
|
+
"frame.rendered.count": "higher",
|
|
6392
|
+
// Frame load is sampled-event weight: less work in a frame is better, and a
|
|
6393
|
+
// higher top-10 share means fewer frames carry it — also better, because it
|
|
6394
|
+
// is a concentration figure, not a throughput one. The span weight is the
|
|
6395
|
+
// denominator for those shares, so it has no direction of its own.
|
|
6396
|
+
"frame.load.avg": "lower",
|
|
6397
|
+
"frame.load.frames.count": "higher",
|
|
6398
|
+
"frame.load.max": "lower",
|
|
6399
|
+
"frame.load.min": "lower",
|
|
6400
|
+
"frame.load.top10.share": "higher",
|
|
6401
|
+
"frame.load.total": "lower",
|
|
6402
|
+
// Every stutter rung is a count of bad frames; fewer is better.
|
|
6403
|
+
"frame.stutter.count": "lower",
|
|
6404
|
+
"frame.stutter.level1.count": "lower",
|
|
6405
|
+
"frame.stutter.level2.count": "lower",
|
|
6406
|
+
"frame.stutter.level3.count": "lower",
|
|
6407
|
+
"frame.stutter.unpaired.count": "lower",
|
|
6408
|
+
// 1 s windows measure rendered frames per second: more is better. The
|
|
6409
|
+
// window count is a capture-length artifact, so it has no direction.
|
|
6410
|
+
"frame.fps.window.max": "higher",
|
|
6411
|
+
"frame.fps.window.mean": "higher",
|
|
6412
|
+
"frame.fps.window.min": "higher",
|
|
6413
|
+
"binder.interfaces.count": "lower",
|
|
6414
|
+
"binder.latency.avg": "lower",
|
|
6415
|
+
"binder.latency.max": "lower",
|
|
6416
|
+
"binder.process.pairs": "lower",
|
|
6417
|
+
"binder.thread.pairs": "lower",
|
|
6418
|
+
"binder.transactions.count": "lower",
|
|
6419
|
+
"thread.instructions.total": "lower",
|
|
6420
|
+
"thread.patterns.count": "lower",
|
|
6421
|
+
"thread.redundant.count": "lower",
|
|
6422
|
+
"thread.redundant.instructions": "lower",
|
|
6423
|
+
"thread.redundant.instructions.ratio": "lower",
|
|
6424
|
+
"mem.measure.rss.avg": "lower",
|
|
6425
|
+
"mem.measure.rss.peak": "lower",
|
|
6426
|
+
"mem.pss.mean": "lower",
|
|
6427
|
+
"mem.pss.peak": "lower",
|
|
6428
|
+
"mem.rss.mean": "lower",
|
|
6429
|
+
"mem.rss.peak": "lower",
|
|
6430
|
+
"mem.samples": "lower",
|
|
6431
|
+
// Native memory: every figure is bytes or counts still held (or churn that
|
|
6432
|
+
// pairs nothing), so less is better. `peak.offset`, `events.count`,
|
|
6433
|
+
// `alloc.*`/`free.*` volume and `callchains.count` are deliberately absent:
|
|
6434
|
+
// they are where and how much activity happened, not how much memory was
|
|
6435
|
+
// retained, and a bigger capture legitimately raises them.
|
|
6436
|
+
"mem.native.free.unpaired.count": "lower",
|
|
6437
|
+
"mem.native.alloc.unaddressed.count": "lower",
|
|
6438
|
+
"mem.native.total.end": "lower",
|
|
6439
|
+
"mem.native.total.peak": "lower",
|
|
6440
|
+
"mem.native.total.trough": "lower",
|
|
6441
|
+
"mem.native.unreleased.end": "lower",
|
|
6442
|
+
"mem.native.unreleased.peak": "lower",
|
|
6443
|
+
"mem.native.unreleased.unattributed.bytes": "lower",
|
|
6444
|
+
"startup.count": "lower",
|
|
6445
|
+
"startup.duration": "lower",
|
|
6446
|
+
"render.fps.live": "higher",
|
|
6447
|
+
"render.hitch.count": "lower",
|
|
6448
|
+
"gc.full.count": "lower",
|
|
6449
|
+
"gc.invocations.count": "lower",
|
|
6450
|
+
"gc.partial.count": "lower",
|
|
6451
|
+
"gc.perf.share": "lower",
|
|
6452
|
+
"gc.rate": "lower",
|
|
6453
|
+
"gc.shared.count": "lower",
|
|
6454
|
+
"gc.shared_full.count": "lower",
|
|
6455
|
+
// `vsync.signals.count` has no direction: more signals is neither better nor
|
|
6456
|
+
// worse, it only changes the denominator of the anomaly rate.
|
|
6457
|
+
"vsync.anomaly.rate": "lower",
|
|
6458
|
+
"vsync.mismatch.count": "lower",
|
|
6459
|
+
"vsync.periods.count": "lower",
|
|
6460
|
+
"empty_frame.count": "lower",
|
|
6461
|
+
"empty_frame.filtered.count": "lower",
|
|
6462
|
+
// Empty frames' sampled load: less work spent drawing nothing is better.
|
|
6463
|
+
"empty_frame.load.share": "lower",
|
|
6464
|
+
"empty_frame.load.total": "lower",
|
|
6465
|
+
"empty_frame.rate": "lower",
|
|
6466
|
+
"rs_skip.events.count": "lower",
|
|
6467
|
+
"rs_skip.frames.count": "lower",
|
|
6468
|
+
// A higher trace accuracy means more of the skipped frames were explained.
|
|
6469
|
+
"rs_skip.trace.accuracy": "higher",
|
|
6470
|
+
"rs_skip.traced.count": "higher",
|
|
6471
|
+
// Fewer builds of the busiest component is the goal, and a higher reuse
|
|
6472
|
+
// rate means more of them came from the recycle pool. `components.top.name`
|
|
6473
|
+
// is a label, not a quantity, so it has no direction.
|
|
6474
|
+
"components.builds.count": "lower",
|
|
6475
|
+
"components.recycled.count": "higher",
|
|
6476
|
+
"components.reuse.rate": "higher"
|
|
6477
|
+
};
|
|
6478
|
+
var STATUSES = [
|
|
6479
|
+
"improved",
|
|
6480
|
+
"regressed",
|
|
6481
|
+
"unchanged",
|
|
6482
|
+
"added",
|
|
6483
|
+
"removed",
|
|
6484
|
+
"incomparable"
|
|
6485
|
+
];
|
|
6486
|
+
function round3(value) {
|
|
6487
|
+
return Math.round(value * 1e3) / 1e3;
|
|
6488
|
+
}
|
|
6489
|
+
function classify(direction, delta2) {
|
|
6490
|
+
if (delta2 === 0) return "unchanged";
|
|
6491
|
+
if (direction === "lower") return delta2 < 0 ? "improved" : "regressed";
|
|
6492
|
+
return delta2 > 0 ? "improved" : "regressed";
|
|
6493
|
+
}
|
|
6494
|
+
function byId2(a, b) {
|
|
6495
|
+
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
6496
|
+
}
|
|
6497
|
+
function compareResults(baseline, current) {
|
|
6498
|
+
const before = new Map(baseline.metrics.map((metric2) => [metric2.id, metric2]));
|
|
6499
|
+
const after = new Map(current.metrics.map((metric2) => [metric2.id, metric2]));
|
|
6500
|
+
const ids = [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort();
|
|
6501
|
+
const rows = ids.map((id) => {
|
|
6502
|
+
const start = before.get(id);
|
|
6503
|
+
const end = after.get(id);
|
|
6504
|
+
if (start === void 0 && end !== void 0) {
|
|
6505
|
+
return {
|
|
6506
|
+
id,
|
|
6507
|
+
unit: end.unit,
|
|
6508
|
+
baseline: null,
|
|
6509
|
+
current: end.value,
|
|
6510
|
+
fidelity: end.fidelity,
|
|
6511
|
+
status: "added"
|
|
6512
|
+
};
|
|
6513
|
+
}
|
|
6514
|
+
if (start !== void 0 && end === void 0) {
|
|
6515
|
+
return {
|
|
6516
|
+
id,
|
|
6517
|
+
unit: start.unit,
|
|
6518
|
+
baseline: start.value,
|
|
6519
|
+
current: null,
|
|
6520
|
+
fidelity: start.fidelity,
|
|
6521
|
+
status: "removed"
|
|
6522
|
+
};
|
|
6523
|
+
}
|
|
6524
|
+
if (start === void 0 || end === void 0) {
|
|
6525
|
+
throw new Error(`unreachable: ${id} present on neither side`);
|
|
6526
|
+
}
|
|
6527
|
+
const base = start.value;
|
|
6528
|
+
const cur = end.value;
|
|
6529
|
+
const numeric = typeof base === "number" && typeof cur === "number";
|
|
6530
|
+
const direction = METRIC_DIRECTIONS[id];
|
|
6531
|
+
const delta2 = numeric ? cur - base : void 0;
|
|
6532
|
+
const deltaPct = numeric && base !== 0 ? round3((cur - base) / Math.abs(base) * 100) : void 0;
|
|
6533
|
+
const status = numeric && direction !== void 0 ? classify(direction, cur - base) : "incomparable";
|
|
6534
|
+
return {
|
|
6535
|
+
id,
|
|
6536
|
+
unit: end.unit,
|
|
6537
|
+
baseline: base,
|
|
6538
|
+
current: cur,
|
|
6539
|
+
...delta2 === void 0 ? {} : { delta: delta2 },
|
|
6540
|
+
...deltaPct === void 0 ? {} : { deltaPct },
|
|
6541
|
+
fidelity: end.fidelity,
|
|
6542
|
+
status
|
|
6543
|
+
};
|
|
6544
|
+
});
|
|
6545
|
+
const totals = Object.fromEntries(STATUSES.map((status) => [status, 0]));
|
|
6546
|
+
for (const row2 of rows) totals[row2.status] += 1;
|
|
6547
|
+
rows.sort(byId2);
|
|
6548
|
+
return { rows, totals };
|
|
6549
|
+
}
|
|
6550
|
+
|
|
6551
|
+
// src/report/scenes.ts
|
|
6552
|
+
function byStepId(a, b) {
|
|
6553
|
+
return a.stepId < b.stepId ? -1 : a.stepId > b.stepId ? 1 : 0;
|
|
6554
|
+
}
|
|
6555
|
+
function compareScenes(baseline, current) {
|
|
6556
|
+
const before = new Map(baseline.map((step) => [step.stepId, step.result]));
|
|
6557
|
+
const after = new Map(current.map((step) => [step.stepId, step.result]));
|
|
6558
|
+
if (before.size !== baseline.length) {
|
|
6559
|
+
throw new Error("compareScenes: the baseline has a duplicate step id");
|
|
6560
|
+
}
|
|
6561
|
+
if (after.size !== current.length) {
|
|
6562
|
+
throw new Error("compareScenes: the current run has a duplicate step id");
|
|
5861
6563
|
}
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
try {
|
|
5868
|
-
text = readFileSync10(entry.path, "utf8");
|
|
5869
|
-
} catch (err) {
|
|
6564
|
+
const ids = [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort();
|
|
6565
|
+
const steps = ids.map((stepId) => {
|
|
6566
|
+
const start = before.get(stepId);
|
|
6567
|
+
const end = after.get(stepId);
|
|
6568
|
+
if (start === void 0 && end !== void 0) {
|
|
5870
6569
|
return {
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
6570
|
+
stepId,
|
|
6571
|
+
status: "added",
|
|
6572
|
+
rows: compareResults({ metrics: [], evidence: [] }, end).rows
|
|
5874
6573
|
};
|
|
5875
6574
|
}
|
|
5876
|
-
|
|
5877
|
-
return {
|
|
5878
|
-
|
|
5879
|
-
|
|
6575
|
+
if (start !== void 0 && end === void 0) {
|
|
6576
|
+
return {
|
|
6577
|
+
stepId,
|
|
6578
|
+
status: "removed",
|
|
6579
|
+
rows: compareResults(start, { metrics: [], evidence: [] }).rows
|
|
6580
|
+
};
|
|
5880
6581
|
}
|
|
6582
|
+
return { stepId, status: "compared", rows: compareResults(start, end).rows };
|
|
5881
6583
|
});
|
|
6584
|
+
return {
|
|
6585
|
+
steps,
|
|
6586
|
+
removed: ids.filter((id) => before.has(id) && !after.has(id)),
|
|
6587
|
+
added: ids.filter((id) => after.has(id) && !before.has(id))
|
|
6588
|
+
};
|
|
5882
6589
|
}
|
|
5883
|
-
function
|
|
5884
|
-
return
|
|
6590
|
+
function renderScenesComparison(comparison) {
|
|
6591
|
+
return `${JSON.stringify(comparison, null, 2)}
|
|
6592
|
+
`;
|
|
5885
6593
|
}
|
|
5886
|
-
function
|
|
5887
|
-
|
|
5888
|
-
return typeof code === "string" ? code : "unreadable";
|
|
6594
|
+
function sortSteps(steps) {
|
|
6595
|
+
return [...steps].sort(byStepId);
|
|
5889
6596
|
}
|
|
5890
6597
|
|
|
5891
6598
|
// src/scenario/actions.ts
|
|
5892
6599
|
var MAX_SCROLLS = 5;
|
|
5893
6600
|
var DEFAULT_DISTANCE = 40;
|
|
5894
|
-
var
|
|
6601
|
+
var POLL_MS2 = 250;
|
|
5895
6602
|
var ACCEPTED_MARKER2 = "No Error";
|
|
5896
|
-
function
|
|
6603
|
+
function detail10(result) {
|
|
5897
6604
|
const lines = `${result.stdout}
|
|
5898
6605
|
${result.stderr}`.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
5899
6606
|
return lines.length === 0 ? "(no output)" : lines.join("; ");
|
|
@@ -5902,7 +6609,7 @@ async function runAa(device, cmd) {
|
|
|
5902
6609
|
const result = await device.shell(cmd);
|
|
5903
6610
|
if (result.code !== 0) {
|
|
5904
6611
|
throw new OhosPerfError(
|
|
5905
|
-
`${cmd.split(" ").slice(0, 2).join(" ")} failed (exit ${result.code}): ${
|
|
6612
|
+
`${cmd.split(" ").slice(0, 2).join(" ")} failed (exit ${result.code}): ${detail10(result)}`,
|
|
5906
6613
|
{ code: "SCENARIO_ACTION_FAILED" }
|
|
5907
6614
|
);
|
|
5908
6615
|
}
|
|
@@ -6025,7 +6732,7 @@ async function resolveWithWait(dump, target, label2, timeoutMs) {
|
|
|
6025
6732
|
return resolveSelector(nodes, target, label2);
|
|
6026
6733
|
}
|
|
6027
6734
|
await new Promise(
|
|
6028
|
-
(resolve2) => setTimeout(resolve2, Math.min(
|
|
6735
|
+
(resolve2) => setTimeout(resolve2, Math.min(POLL_MS2, remaining))
|
|
6029
6736
|
);
|
|
6030
6737
|
}
|
|
6031
6738
|
}
|
|
@@ -9152,11 +9859,11 @@ function basename2(filePath) {
|
|
|
9152
9859
|
}
|
|
9153
9860
|
function kmpPackage(symbol) {
|
|
9154
9861
|
const path = symbol.slice("kfun:".length).split("#")[0];
|
|
9155
|
-
const
|
|
9156
|
-
if (
|
|
9157
|
-
|
|
9158
|
-
while (
|
|
9159
|
-
return
|
|
9862
|
+
const segments2 = path.split(".").filter((s) => s.length > 0);
|
|
9863
|
+
if (segments2.length <= 1) return "kotlin";
|
|
9864
|
+
segments2.pop();
|
|
9865
|
+
while (segments2.length > 1 && /^[A-Z]/.test(segments2[segments2.length - 1])) segments2.pop();
|
|
9866
|
+
return segments2.join(".");
|
|
9160
9867
|
}
|
|
9161
9868
|
function refine(base, symbol) {
|
|
9162
9869
|
if (symbol === null) return base;
|
|
@@ -11343,8 +12050,8 @@ var ThreadAnalyzer = class {
|
|
|
11343
12050
|
// src/query/registry.ts
|
|
11344
12051
|
var DEFAULT_QUERY_LIMIT = 100;
|
|
11345
12052
|
var MAX_QUERY_LIMIT = 1e3;
|
|
11346
|
-
function badArgs(query,
|
|
11347
|
-
return new OhosPerfError(`${query}: ${
|
|
12053
|
+
function badArgs(query, detail11) {
|
|
12054
|
+
return new OhosPerfError(`${query}: ${detail11}`, { code: "QUERY_BAD_ARGS" });
|
|
11348
12055
|
}
|
|
11349
12056
|
function rejectUnknownArgs(query, args, allowed) {
|
|
11350
12057
|
for (const key of Object.keys(args)) {
|
|
@@ -12858,6 +13565,36 @@ function byMetricId7(a, b) {
|
|
|
12858
13565
|
if (a.id > b.id) return 1;
|
|
12859
13566
|
return 0;
|
|
12860
13567
|
}
|
|
13568
|
+
function ipcBinderMetrics(analysis, ctx) {
|
|
13569
|
+
if (analysis === void 0) return [];
|
|
13570
|
+
const completed = analysis.transactions.filter((tx) => tx.latencyMs !== null);
|
|
13571
|
+
if (completed.length === 0) return [];
|
|
13572
|
+
const latencies = completed.map((tx) => tx.latencyMs);
|
|
13573
|
+
let total = 0;
|
|
13574
|
+
let max = latencies[0];
|
|
13575
|
+
for (const latency of latencies) {
|
|
13576
|
+
total += latency;
|
|
13577
|
+
if (latency > max) max = latency;
|
|
13578
|
+
}
|
|
13579
|
+
const rows = analysis.transactions.length;
|
|
13580
|
+
const make = (id, value, unit) => metric({
|
|
13581
|
+
id,
|
|
13582
|
+
value,
|
|
13583
|
+
unit,
|
|
13584
|
+
fidelity: "exact",
|
|
13585
|
+
provenance: {
|
|
13586
|
+
collector: "hitrace+streamer",
|
|
13587
|
+
table: "binder_transaction",
|
|
13588
|
+
rows,
|
|
13589
|
+
device: ctx.deviceId
|
|
13590
|
+
}
|
|
13591
|
+
});
|
|
13592
|
+
return [
|
|
13593
|
+
make("fault.ipc_binder.transactions.count", analysis.transactions.length, "count"),
|
|
13594
|
+
make("fault.ipc_binder.latency.avg", total / latencies.length, "ms"),
|
|
13595
|
+
make("fault.ipc_binder.latency.max", max, "ms")
|
|
13596
|
+
];
|
|
13597
|
+
}
|
|
12861
13598
|
function byEvidenceOrder7(a, b) {
|
|
12862
13599
|
if (a.kind < b.kind) return -1;
|
|
12863
13600
|
if (a.kind > b.kind) return 1;
|
|
@@ -12886,6 +13623,8 @@ var FaultTreeAnalyzer = class {
|
|
|
12886
13623
|
}
|
|
12887
13624
|
const metrics = faultMetrics(signals, rows, ctx);
|
|
12888
13625
|
const evidenceItems = faultEvidence(signals, ctx);
|
|
13626
|
+
const binder = ctx.binderAnalysis ?? (hasTable2(ctx.db, "args") ? computeBinderAnalysis(ctx.db, { appPids: ctx.app.pids }) : void 0);
|
|
13627
|
+
metrics.push(...ipcBinderMetrics(binder, ctx));
|
|
12889
13628
|
metrics.sort(byMetricId7);
|
|
12890
13629
|
evidenceItems.sort(byEvidenceOrder7);
|
|
12891
13630
|
return { metrics, evidence: evidenceItems };
|
|
@@ -14802,6 +15541,10 @@ var RsSkipAnalyzer = class {
|
|
|
14802
15541
|
})
|
|
14803
15542
|
];
|
|
14804
15543
|
if (appKnown) {
|
|
15544
|
+
let wasteNs = 0;
|
|
15545
|
+
for (const entry of result.frames) {
|
|
15546
|
+
if (entry.traced !== void 0) wasteNs += entry.traced.frame.dur;
|
|
15547
|
+
}
|
|
14805
15548
|
metrics.push(
|
|
14806
15549
|
metric({
|
|
14807
15550
|
id: "rs_skip.trace.accuracy",
|
|
@@ -14820,6 +15563,18 @@ var RsSkipAnalyzer = class {
|
|
|
14820
15563
|
window: ctx.window
|
|
14821
15564
|
})
|
|
14822
15565
|
);
|
|
15566
|
+
if (wasteNs > 0) {
|
|
15567
|
+
metrics.push(
|
|
15568
|
+
metric({
|
|
15569
|
+
id: "rs_skip.cpu_waste.ms",
|
|
15570
|
+
value: wasteNs / 1e6,
|
|
15571
|
+
unit: "ms",
|
|
15572
|
+
provenance: prov,
|
|
15573
|
+
fidelity: "exact",
|
|
15574
|
+
window: ctx.window
|
|
15575
|
+
})
|
|
15576
|
+
);
|
|
15577
|
+
}
|
|
14823
15578
|
} else {
|
|
14824
15579
|
metrics.push(
|
|
14825
15580
|
metric({
|
|
@@ -15274,7 +16029,8 @@ function defaultAnalyzers() {
|
|
|
15274
16029
|
new FlamegraphAnalyzer(),
|
|
15275
16030
|
new ComponentReuseAnalyzer(),
|
|
15276
16031
|
new HilogAnalyzer(),
|
|
15277
|
-
new UiAnalyzer()
|
|
16032
|
+
new UiAnalyzer(),
|
|
16033
|
+
new RedundantFileAnalyzer()
|
|
15278
16034
|
];
|
|
15279
16035
|
}
|
|
15280
16036
|
|
|
@@ -16337,173 +17093,6 @@ function hapSection(analysis) {
|
|
|
16337
17093
|
};
|
|
16338
17094
|
}
|
|
16339
17095
|
|
|
16340
|
-
// src/report/compare.ts
|
|
16341
|
-
var METRIC_DIRECTIONS = {
|
|
16342
|
-
"frame.avg.duration": "lower",
|
|
16343
|
-
"frame.count": "higher",
|
|
16344
|
-
"frame.empty.rate": "lower",
|
|
16345
|
-
"frame.fps": "higher",
|
|
16346
|
-
"frame.jank.rate": "lower",
|
|
16347
|
-
"frame.rendered.count": "higher",
|
|
16348
|
-
// Frame load is sampled-event weight: less work in a frame is better, and a
|
|
16349
|
-
// higher top-10 share means fewer frames carry it — also better, because it
|
|
16350
|
-
// is a concentration figure, not a throughput one. The span weight is the
|
|
16351
|
-
// denominator for those shares, so it has no direction of its own.
|
|
16352
|
-
"frame.load.avg": "lower",
|
|
16353
|
-
"frame.load.frames.count": "higher",
|
|
16354
|
-
"frame.load.max": "lower",
|
|
16355
|
-
"frame.load.min": "lower",
|
|
16356
|
-
"frame.load.top10.share": "higher",
|
|
16357
|
-
"frame.load.total": "lower",
|
|
16358
|
-
// Every stutter rung is a count of bad frames; fewer is better.
|
|
16359
|
-
"frame.stutter.count": "lower",
|
|
16360
|
-
"frame.stutter.level1.count": "lower",
|
|
16361
|
-
"frame.stutter.level2.count": "lower",
|
|
16362
|
-
"frame.stutter.level3.count": "lower",
|
|
16363
|
-
"frame.stutter.unpaired.count": "lower",
|
|
16364
|
-
// 1 s windows measure rendered frames per second: more is better. The
|
|
16365
|
-
// window count is a capture-length artifact, so it has no direction.
|
|
16366
|
-
"frame.fps.window.max": "higher",
|
|
16367
|
-
"frame.fps.window.mean": "higher",
|
|
16368
|
-
"frame.fps.window.min": "higher",
|
|
16369
|
-
"binder.interfaces.count": "lower",
|
|
16370
|
-
"binder.latency.avg": "lower",
|
|
16371
|
-
"binder.latency.max": "lower",
|
|
16372
|
-
"binder.process.pairs": "lower",
|
|
16373
|
-
"binder.thread.pairs": "lower",
|
|
16374
|
-
"binder.transactions.count": "lower",
|
|
16375
|
-
"thread.instructions.total": "lower",
|
|
16376
|
-
"thread.patterns.count": "lower",
|
|
16377
|
-
"thread.redundant.count": "lower",
|
|
16378
|
-
"thread.redundant.instructions": "lower",
|
|
16379
|
-
"thread.redundant.instructions.ratio": "lower",
|
|
16380
|
-
"mem.measure.rss.avg": "lower",
|
|
16381
|
-
"mem.measure.rss.peak": "lower",
|
|
16382
|
-
"mem.pss.mean": "lower",
|
|
16383
|
-
"mem.pss.peak": "lower",
|
|
16384
|
-
"mem.rss.mean": "lower",
|
|
16385
|
-
"mem.rss.peak": "lower",
|
|
16386
|
-
"mem.samples": "lower",
|
|
16387
|
-
// Native memory: every figure is bytes or counts still held (or churn that
|
|
16388
|
-
// pairs nothing), so less is better. `peak.offset`, `events.count`,
|
|
16389
|
-
// `alloc.*`/`free.*` volume and `callchains.count` are deliberately absent:
|
|
16390
|
-
// they are where and how much activity happened, not how much memory was
|
|
16391
|
-
// retained, and a bigger capture legitimately raises them.
|
|
16392
|
-
"mem.native.free.unpaired.count": "lower",
|
|
16393
|
-
"mem.native.alloc.unaddressed.count": "lower",
|
|
16394
|
-
"mem.native.total.end": "lower",
|
|
16395
|
-
"mem.native.total.peak": "lower",
|
|
16396
|
-
"mem.native.total.trough": "lower",
|
|
16397
|
-
"mem.native.unreleased.end": "lower",
|
|
16398
|
-
"mem.native.unreleased.peak": "lower",
|
|
16399
|
-
"mem.native.unreleased.unattributed.bytes": "lower",
|
|
16400
|
-
"startup.count": "lower",
|
|
16401
|
-
"startup.duration": "lower",
|
|
16402
|
-
"render.fps.live": "higher",
|
|
16403
|
-
"render.hitch.count": "lower",
|
|
16404
|
-
"gc.full.count": "lower",
|
|
16405
|
-
"gc.invocations.count": "lower",
|
|
16406
|
-
"gc.partial.count": "lower",
|
|
16407
|
-
"gc.perf.share": "lower",
|
|
16408
|
-
"gc.rate": "lower",
|
|
16409
|
-
"gc.shared.count": "lower",
|
|
16410
|
-
"gc.shared_full.count": "lower",
|
|
16411
|
-
// `vsync.signals.count` has no direction: more signals is neither better nor
|
|
16412
|
-
// worse, it only changes the denominator of the anomaly rate.
|
|
16413
|
-
"vsync.anomaly.rate": "lower",
|
|
16414
|
-
"vsync.mismatch.count": "lower",
|
|
16415
|
-
"vsync.periods.count": "lower",
|
|
16416
|
-
"empty_frame.count": "lower",
|
|
16417
|
-
"empty_frame.filtered.count": "lower",
|
|
16418
|
-
// Empty frames' sampled load: less work spent drawing nothing is better.
|
|
16419
|
-
"empty_frame.load.share": "lower",
|
|
16420
|
-
"empty_frame.load.total": "lower",
|
|
16421
|
-
"empty_frame.rate": "lower",
|
|
16422
|
-
"rs_skip.events.count": "lower",
|
|
16423
|
-
"rs_skip.frames.count": "lower",
|
|
16424
|
-
// A higher trace accuracy means more of the skipped frames were explained.
|
|
16425
|
-
"rs_skip.trace.accuracy": "higher",
|
|
16426
|
-
"rs_skip.traced.count": "higher",
|
|
16427
|
-
// Fewer builds of the busiest component is the goal, and a higher reuse
|
|
16428
|
-
// rate means more of them came from the recycle pool. `components.top.name`
|
|
16429
|
-
// is a label, not a quantity, so it has no direction.
|
|
16430
|
-
"components.builds.count": "lower",
|
|
16431
|
-
"components.recycled.count": "higher",
|
|
16432
|
-
"components.reuse.rate": "higher"
|
|
16433
|
-
};
|
|
16434
|
-
var STATUSES = [
|
|
16435
|
-
"improved",
|
|
16436
|
-
"regressed",
|
|
16437
|
-
"unchanged",
|
|
16438
|
-
"added",
|
|
16439
|
-
"removed",
|
|
16440
|
-
"incomparable"
|
|
16441
|
-
];
|
|
16442
|
-
function round3(value) {
|
|
16443
|
-
return Math.round(value * 1e3) / 1e3;
|
|
16444
|
-
}
|
|
16445
|
-
function classify(direction, delta2) {
|
|
16446
|
-
if (delta2 === 0) return "unchanged";
|
|
16447
|
-
if (direction === "lower") return delta2 < 0 ? "improved" : "regressed";
|
|
16448
|
-
return delta2 > 0 ? "improved" : "regressed";
|
|
16449
|
-
}
|
|
16450
|
-
function byId2(a, b) {
|
|
16451
|
-
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
16452
|
-
}
|
|
16453
|
-
function compareResults(baseline, current) {
|
|
16454
|
-
const before = new Map(baseline.metrics.map((metric2) => [metric2.id, metric2]));
|
|
16455
|
-
const after = new Map(current.metrics.map((metric2) => [metric2.id, metric2]));
|
|
16456
|
-
const ids = [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort();
|
|
16457
|
-
const rows = ids.map((id) => {
|
|
16458
|
-
const start = before.get(id);
|
|
16459
|
-
const end = after.get(id);
|
|
16460
|
-
if (start === void 0 && end !== void 0) {
|
|
16461
|
-
return {
|
|
16462
|
-
id,
|
|
16463
|
-
unit: end.unit,
|
|
16464
|
-
baseline: null,
|
|
16465
|
-
current: end.value,
|
|
16466
|
-
fidelity: end.fidelity,
|
|
16467
|
-
status: "added"
|
|
16468
|
-
};
|
|
16469
|
-
}
|
|
16470
|
-
if (start !== void 0 && end === void 0) {
|
|
16471
|
-
return {
|
|
16472
|
-
id,
|
|
16473
|
-
unit: start.unit,
|
|
16474
|
-
baseline: start.value,
|
|
16475
|
-
current: null,
|
|
16476
|
-
fidelity: start.fidelity,
|
|
16477
|
-
status: "removed"
|
|
16478
|
-
};
|
|
16479
|
-
}
|
|
16480
|
-
if (start === void 0 || end === void 0) {
|
|
16481
|
-
throw new Error(`unreachable: ${id} present on neither side`);
|
|
16482
|
-
}
|
|
16483
|
-
const base = start.value;
|
|
16484
|
-
const cur = end.value;
|
|
16485
|
-
const numeric = typeof base === "number" && typeof cur === "number";
|
|
16486
|
-
const direction = METRIC_DIRECTIONS[id];
|
|
16487
|
-
const delta2 = numeric ? cur - base : void 0;
|
|
16488
|
-
const deltaPct = numeric && base !== 0 ? round3((cur - base) / Math.abs(base) * 100) : void 0;
|
|
16489
|
-
const status = numeric && direction !== void 0 ? classify(direction, cur - base) : "incomparable";
|
|
16490
|
-
return {
|
|
16491
|
-
id,
|
|
16492
|
-
unit: end.unit,
|
|
16493
|
-
baseline: base,
|
|
16494
|
-
current: cur,
|
|
16495
|
-
...delta2 === void 0 ? {} : { delta: delta2 },
|
|
16496
|
-
...deltaPct === void 0 ? {} : { deltaPct },
|
|
16497
|
-
fidelity: end.fidelity,
|
|
16498
|
-
status
|
|
16499
|
-
};
|
|
16500
|
-
});
|
|
16501
|
-
const totals = Object.fromEntries(STATUSES.map((status) => [status, 0]));
|
|
16502
|
-
for (const row2 of rows) totals[row2.status] += 1;
|
|
16503
|
-
rows.sort(byId2);
|
|
16504
|
-
return { rows, totals };
|
|
16505
|
-
}
|
|
16506
|
-
|
|
16507
17096
|
// src/report/model.ts
|
|
16508
17097
|
var REPORT_SCHEMA_VERSION = 1;
|
|
16509
17098
|
var SECTION_TITLES = {
|
|
@@ -17163,11 +17752,11 @@ function buildTree(stacks) {
|
|
|
17163
17752
|
}
|
|
17164
17753
|
const nodes = /* @__PURE__ */ new Map();
|
|
17165
17754
|
for (const [path, weight] of weights) {
|
|
17166
|
-
const
|
|
17755
|
+
const segments2 = path.split(";");
|
|
17167
17756
|
nodes.set(path, {
|
|
17168
17757
|
path,
|
|
17169
|
-
name:
|
|
17170
|
-
depth:
|
|
17758
|
+
name: segments2[segments2.length - 1],
|
|
17759
|
+
depth: segments2.length - 1,
|
|
17171
17760
|
weight,
|
|
17172
17761
|
children: []
|
|
17173
17762
|
});
|
|
@@ -17367,6 +17956,7 @@ export {
|
|
|
17367
17956
|
IGNORED_ATTRIBUTES,
|
|
17368
17957
|
IngestError,
|
|
17369
17958
|
InstantQuery,
|
|
17959
|
+
JsheapCollector,
|
|
17370
17960
|
MAX_QUERY_LIMIT,
|
|
17371
17961
|
METRIC_DIRECTIONS,
|
|
17372
17962
|
MIN_BUFFER_PAGES,
|
|
@@ -17376,11 +17966,13 @@ export {
|
|
|
17376
17966
|
NativeHookQuery,
|
|
17377
17967
|
NativeMemoryAnalyzer,
|
|
17378
17968
|
OhosPerfError,
|
|
17969
|
+
PARITY_ROWS,
|
|
17379
17970
|
PLANE_A_PLUGINS,
|
|
17380
17971
|
PerfQuery,
|
|
17381
17972
|
ProcessQuery,
|
|
17382
17973
|
ProcfsCollector,
|
|
17383
17974
|
REPORT_SCHEMA_VERSION,
|
|
17975
|
+
RedundantFileAnalyzer,
|
|
17384
17976
|
RenderAnalyzer,
|
|
17385
17977
|
RsSkipAnalyzer,
|
|
17386
17978
|
SECTION_TITLES,
|
|
@@ -17404,6 +17996,7 @@ export {
|
|
|
17404
17996
|
aggregateUnreleased,
|
|
17405
17997
|
analyzeHap,
|
|
17406
17998
|
analyzeThreadWakeup,
|
|
17999
|
+
buildDepGraph,
|
|
17407
18000
|
buildHiprofilerConfig,
|
|
17408
18001
|
buildInventory,
|
|
17409
18002
|
buildMatrix,
|
|
@@ -17414,6 +18007,7 @@ export {
|
|
|
17414
18007
|
compareImages,
|
|
17415
18008
|
compareResults,
|
|
17416
18009
|
compareSceneDirs,
|
|
18010
|
+
compareScenes,
|
|
17417
18011
|
compileRules,
|
|
17418
18012
|
computeBinderAnalysis,
|
|
17419
18013
|
computeComponentReuse,
|
|
@@ -17457,6 +18051,7 @@ export {
|
|
|
17457
18051
|
openDb,
|
|
17458
18052
|
openZip,
|
|
17459
18053
|
pairNativeMemory,
|
|
18054
|
+
paritySummary,
|
|
17460
18055
|
parseBounds,
|
|
17461
18056
|
parseFpsCounts,
|
|
17462
18057
|
parseHilogLine,
|
|
@@ -17464,12 +18059,14 @@ export {
|
|
|
17464
18059
|
parseHiperfSummary,
|
|
17465
18060
|
parseHitches,
|
|
17466
18061
|
parseProcfsStatus,
|
|
18062
|
+
parseRedundantFile,
|
|
17467
18063
|
parseScenario,
|
|
17468
18064
|
parseSelector,
|
|
17469
18065
|
parseSmapsRollup,
|
|
17470
18066
|
queryDefinitions,
|
|
17471
18067
|
readHidumperCapture,
|
|
17472
18068
|
readHilogText,
|
|
18069
|
+
readJsheapSnapshot,
|
|
17473
18070
|
readProcfsSamples,
|
|
17474
18071
|
readSceneMetadata,
|
|
17475
18072
|
readUiTree,
|
|
@@ -17480,6 +18077,7 @@ export {
|
|
|
17480
18077
|
renderReportHtml,
|
|
17481
18078
|
renderReportJson,
|
|
17482
18079
|
renderReportXlsx,
|
|
18080
|
+
renderScenesComparison,
|
|
17483
18081
|
renderSummaryJson,
|
|
17484
18082
|
renderUiDiffHtml,
|
|
17485
18083
|
resolveAppIdentity,
|
|
@@ -17492,6 +18090,7 @@ export {
|
|
|
17492
18090
|
runDrillDown,
|
|
17493
18091
|
runNamedQuery,
|
|
17494
18092
|
runProbe,
|
|
18093
|
+
sortSteps,
|
|
17495
18094
|
summarizeReport,
|
|
17496
18095
|
tableRowCounts,
|
|
17497
18096
|
unknownQueryError,
|