@ohos-perf/core 0.15.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +284 -178
  2. package/dist/index.js +251 -25
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4071,6 +4071,289 @@ declare function renderScenesComparison(comparison: ScenesComparison): string;
4071
4071
  /** Sorts steps by id; exported for a caller assembling them from a run. */
4072
4072
  declare function sortSteps(steps: readonly SceneStep[]): SceneStep[];
4073
4073
 
4074
+ /**
4075
+ * One analyzer's share of a run.
4076
+ *
4077
+ * A skipped analyzer still gets a section, with `status: 'degraded'` and the
4078
+ * placeholder metric/evidence pair the engine synthesizes, so a report can
4079
+ * name the missing capability in place instead of dropping the section.
4080
+ */
4081
+ interface AnalyzerSection {
4082
+ readonly analyzerId: string;
4083
+ readonly status: 'measured' | 'degraded';
4084
+ readonly result: AnalyzeResult;
4085
+ }
4086
+ /** A whole run: the merged result plus the per-analyzer sections it came from. */
4087
+ interface AnalyzerRun {
4088
+ readonly result: AnalyzeResult;
4089
+ readonly sections: AnalyzerSection[];
4090
+ }
4091
+ /**
4092
+ * Runs every analyzer whose capability requirements are satisfied.
4093
+ *
4094
+ * Analyzers are sorted by `id` and run sequentially, so both the call order
4095
+ * and the merged output are deterministic regardless of the caller's array
4096
+ * order (D5). An analyzer with an unsatisfied requirement is not called: it
4097
+ * contributes one `<id>.degraded` proxy metric and one `degraded_capability`
4098
+ * evidence item naming the missing capabilities and the device's own reasons.
4099
+ * Every analyzer also contributes one {@link AnalyzerSection} to `sections`,
4100
+ * in the same id order, so a report can attribute each metric to its source.
4101
+ *
4102
+ * The returned arrays are new and sorted (`metrics` by `id`, `evidence` by
4103
+ * `(kind, window.startNs, id)`). Two analyzers emitting the same metric id
4104
+ * make the report ambiguous, so the whole run fails with
4105
+ * `DUPLICATE_METRIC_ID` instead of silently keeping one value; the same
4106
+ * integrity rule applies to evidence ids (`DUPLICATE_EVIDENCE_ID`). Neither
4107
+ * the context nor any analyzer (including its result arrays) is mutated.
4108
+ */
4109
+ declare function runAnalyzerSections(analyzers: readonly Analyzer[], ctx: AnalyzeContext): Promise<AnalyzerRun>;
4110
+ /**
4111
+ * Runs every analyzer and returns only the merged result.
4112
+ *
4113
+ * A thin wrapper over {@link runAnalyzerSections}; existing callers keep the
4114
+ * old shape and behavior exactly.
4115
+ */
4116
+ declare function runAnalyzers(analyzers: readonly Analyzer[], ctx: AnalyzeContext): Promise<AnalyzeResult>;
4117
+ /**
4118
+ * The analyzers an offline `analyze` run executes by default.
4119
+ *
4120
+ * Additional analyzers are appended as they are implemented; the function
4121
+ * returns a fresh array so callers may add or remove entries without
4122
+ * affecting another run.
4123
+ */
4124
+ declare function defaultAnalyzers(): Analyzer[];
4125
+
4126
+ /** The report document schema. A change to any shape below bumps this. */
4127
+ declare const REPORT_SCHEMA_VERSION = 1;
4128
+ /** Who produced the report; the version is the CLI package version. */
4129
+ interface ReportGenerator {
4130
+ name: string;
4131
+ version: string;
4132
+ }
4133
+ /** The scene the report describes. Inputs are copied, never referenced. */
4134
+ interface ReportScenario {
4135
+ app: {
4136
+ packageName: string;
4137
+ processNames: string[];
4138
+ };
4139
+ device: string;
4140
+ window: TimeRange;
4141
+ /** Capture start from `scene.json`; absent when the scene did not record one. */
4142
+ startedAtNs?: number;
4143
+ /**
4144
+ * The screenshot the bundle carries at `assets/screenshot.png`. Present only
4145
+ * when the scene had one, so a renderer can tell "no image" from "an image
4146
+ * whose size it was not told".
4147
+ */
4148
+ screenshot?: {
4149
+ width: number;
4150
+ height: number;
4151
+ };
4152
+ }
4153
+ /** One analyzer's contribution, ready for rendering. */
4154
+ interface ReportSection {
4155
+ /** The analyzer id, e.g. `frames`. Also the HTML section anchor. */
4156
+ id: string;
4157
+ title: string;
4158
+ status: 'measured' | 'degraded';
4159
+ /** The engine's explanation of why the analyzer was skipped. */
4160
+ degradedReason?: string;
4161
+ /** Sorted by `id`, as the engine emits them. */
4162
+ metrics: Metric[];
4163
+ /** Sorted by `(kind, window.startNs, id)`, as the engine emits them. */
4164
+ evidence: Evidence[];
4165
+ }
4166
+ interface ReportTotals {
4167
+ metrics: number;
4168
+ evidence: number;
4169
+ bySeverity: {
4170
+ info: number;
4171
+ warn: number;
4172
+ critical: number;
4173
+ };
4174
+ measured: number;
4175
+ degraded: number;
4176
+ }
4177
+ /** The complete, versioned report document. */
4178
+ interface ReportModel {
4179
+ schemaVersion: typeof REPORT_SCHEMA_VERSION;
4180
+ generator: ReportGenerator;
4181
+ scenario: ReportScenario;
4182
+ sections: ReportSection[];
4183
+ totals: ReportTotals;
4184
+ comparison?: BaselineComparison;
4185
+ }
4186
+ /** Everything `buildReport` needs; all values are already measured. */
4187
+ interface ReportInput {
4188
+ generator: ReportGenerator;
4189
+ app: AppIdentity;
4190
+ device: string;
4191
+ window: TimeRange;
4192
+ startedAtNs?: number;
4193
+ sections: readonly AnalyzerSection[];
4194
+ comparison?: BaselineComparison;
4195
+ /**
4196
+ * The scene's screenshot dimensions, when one was captured. The report copies
4197
+ * the file to `assets/screenshot.png` and renders it in the `ui` section; the
4198
+ * dimensions are here so the page can state them without decoding the PNG
4199
+ * again. Absent means no image was captured, and the page says so instead of
4200
+ * pointing at a file that does not exist.
4201
+ */
4202
+ screenshot?: {
4203
+ width: number;
4204
+ height: number;
4205
+ };
4206
+ }
4207
+ /** The compact roll-up written to `summary.json`. */
4208
+ interface ReportSummary {
4209
+ schemaVersion: typeof REPORT_SCHEMA_VERSION;
4210
+ app: string;
4211
+ device: string;
4212
+ window: TimeRange;
4213
+ sections: Array<{
4214
+ id: string;
4215
+ title: string;
4216
+ status: 'measured' | 'degraded';
4217
+ degradedReason?: string;
4218
+ metrics: number;
4219
+ evidence: number;
4220
+ }>;
4221
+ totals: ReportTotals;
4222
+ comparison?: Record<DeltaStatus, number>;
4223
+ }
4224
+ /**
4225
+ * Human titles for the analyzers shipped today.
4226
+ *
4227
+ * An id absent here titles as itself: a new analyzer renders honestly before
4228
+ * anyone writes its title, instead of failing the report.
4229
+ */
4230
+ declare const SECTION_TITLES: Readonly<Record<string, string>>;
4231
+ /**
4232
+ * Builds the report document from a section-aware engine run.
4233
+ *
4234
+ * The inputs are copied and sorted, never mutated. Sorting repeats the engine's
4235
+ * order so a model assembled by hand (as in tests) is just as deterministic as
4236
+ * one produced by `runAnalyzerSections` — the report must be byte-stable (D5)
4237
+ * no matter which layer produced its parts.
4238
+ */
4239
+ declare function buildReport(input: ReportInput): ReportModel;
4240
+ /** Collapses the model to its per-section counts and totals. */
4241
+ declare function summarizeReport(model: ReportModel): ReportSummary;
4242
+ /**
4243
+ * The canonical JSON serialization for `report.json` and `summary.json`.
4244
+ *
4245
+ * Two-space indent plus a trailing newline matches `analyze --json`, so a
4246
+ * consumer reads every document in this package the same way.
4247
+ */
4248
+ declare function renderReportJson(model: ReportModel): string;
4249
+ declare function renderSummaryJson(summary: ReportSummary): string;
4250
+
4251
+ /**
4252
+ * Multi-run trend aggregation (HapRay parity row 35, the aggregation half).
4253
+ *
4254
+ * HapRay's `PerfMulti.vue` accepts any set of report HTML files, extracts the
4255
+ * embedded JSON from each, and draws the total load and the per-category load
4256
+ * across them. It asks the user to filter by app, ROM version, app version and
4257
+ * scene — because the page has no model that could tell comparable runs from
4258
+ * incomparable ones, so the filtering is left to a human reading four
4259
+ * dropdowns.
4260
+ *
4261
+ * A trend line is a claim that the runs are comparable: that the same app was
4262
+ * measured the same way, and that a movement along the x axis is a change in
4263
+ * the app rather than a change in what was measured. So this module refuses
4264
+ * the inputs that make the claim false — different apps, a duplicated label —
4265
+ * and makes the rest of the claim visible: the ordering is stated, a metric a
4266
+ * run never emitted is a gap rather than a zero, and a delta is taken between
4267
+ * the first and last run that actually measured the metric.
4268
+ *
4269
+ * ## What a gap means
4270
+ *
4271
+ * Plotting 0 for "this run did not emit `frame.count`" would draw a collapse
4272
+ * to zero and a recovery, which is a much stronger claim than "the analyzer
4273
+ * did not run". The point is `null`, the series counts its `measured` points,
4274
+ * and the HTML prints the count beside the name. A *degraded* metric counts as
4275
+ * a gap too: its zero is the engine's stand-in for "nothing to read", so a
4276
+ * series of them is a series of gaps — kept, so the metric that was not
4277
+ * measured is named, but drawn as nothing.
4278
+ */
4279
+ /** One run's metrics, named and identified well enough to be compared. */
4280
+ interface TrendRun {
4281
+ /** Unique across the trend; the x-axis label. */
4282
+ readonly label: string;
4283
+ readonly app: string;
4284
+ readonly device: string;
4285
+ /** Capture start, when the run recorded one. Absent disables time ordering. */
4286
+ readonly startedAtNs?: number;
4287
+ readonly metrics: readonly Metric[];
4288
+ }
4289
+ /** One run's value for one metric; `null` when the run did not emit it. */
4290
+ interface TrendPoint {
4291
+ readonly label: string;
4292
+ readonly value: number | string | null;
4293
+ /** The metric's fidelity in this run, when it emitted the metric. */
4294
+ readonly fidelity?: Metric['fidelity'];
4295
+ }
4296
+ interface TrendSeries {
4297
+ readonly id: string;
4298
+ readonly unit: Metric['unit'];
4299
+ /** One point per run, in `TrendOrder` order. */
4300
+ readonly points: readonly TrendPoint[];
4301
+ /** How many runs emitted the metric. */
4302
+ readonly measured: number;
4303
+ /** Difference between the first and last measured numeric points. */
4304
+ readonly delta?: number;
4305
+ /** Percent change over the same two points; absent when the first is 0. */
4306
+ readonly deltaPct?: number;
4307
+ /**
4308
+ * `improved` / `regressed` / `unchanged` when the metric has a known
4309
+ * direction and both ends are numeric; absent otherwise. Unlike a two-way
4310
+ * comparison there is no `added`/`removed`/`incomparable` here: a series
4311
+ * exists because at least one run emitted it, and a metric with no known
4312
+ * direction simply carries no verdict.
4313
+ */
4314
+ readonly status?: 'improved' | 'regressed' | 'unchanged';
4315
+ /** Every run's fidelity, deduplicated and sorted; more than one means mixed. */
4316
+ readonly fidelities: readonly Metric['fidelity'][];
4317
+ }
4318
+ /** How the runs were ordered. Stated so a reader knows what the x axis means. */
4319
+ type TrendOrder = 'startedAtNs' | 'argument';
4320
+ interface Trend {
4321
+ readonly runs: readonly TrendRun[];
4322
+ readonly orderedBy: TrendOrder;
4323
+ /** Sorted by id, so two renders of the same input are byte-identical. */
4324
+ readonly series: readonly TrendSeries[];
4325
+ }
4326
+ /**
4327
+ * Aggregate two or more runs into one trend.
4328
+ *
4329
+ * Throws — rather than filtering silently — when the inputs cannot support the
4330
+ * claim: fewer than two runs, a duplicate label (the x axis would have two
4331
+ * points in one column), or runs from different apps. `device` is deliberately
4332
+ * not a refusal: a trend across two devices is a legitimate question, and the
4333
+ * runs table names the device of every point so the reader can see it.
4334
+ */
4335
+ declare function buildTrend(runs: readonly TrendRun[]): Trend;
4336
+ /** The canonical JSON serialization for `trend.json`. */
4337
+ declare function renderTrendJson(trend: Trend): string;
4338
+ /**
4339
+ * Flatten one saved report into a run.
4340
+ *
4341
+ * The report model is the input because it is what `report` writes to disk:
4342
+ * the metrics are already sorted by id per section, so the flattened list is
4343
+ * deterministic without a second sort. A section with no metrics contributes
4344
+ * nothing; the run's `metrics.length` is the sum the runs table reports.
4345
+ */
4346
+ declare function trendRunFromReport(label: string, model: ReportModel): TrendRun;
4347
+ /**
4348
+ * Render the trend as one self-contained HTML document.
4349
+ *
4350
+ * Same rules as the report page: no scripts, no external resources, every
4351
+ * interpolation escaped. The runs table names each run's label, app, device
4352
+ * and start so the reader can judge comparability themselves; the series
4353
+ * table carries the numbers a polyline cannot show.
4354
+ */
4355
+ declare function renderTrendHtml(trend: Trend): string;
4356
+
4074
4357
  /**
4075
4358
  * Executing one scenario action against a device.
4076
4359
  *
@@ -5523,58 +5806,6 @@ declare class ComponentReuseAnalyzer implements Analyzer {
5523
5806
  run(ctx: AnalyzeContext): Promise<AnalyzeResult>;
5524
5807
  }
5525
5808
 
5526
- /**
5527
- * One analyzer's share of a run.
5528
- *
5529
- * A skipped analyzer still gets a section, with `status: 'degraded'` and the
5530
- * placeholder metric/evidence pair the engine synthesizes, so a report can
5531
- * name the missing capability in place instead of dropping the section.
5532
- */
5533
- interface AnalyzerSection {
5534
- readonly analyzerId: string;
5535
- readonly status: 'measured' | 'degraded';
5536
- readonly result: AnalyzeResult;
5537
- }
5538
- /** A whole run: the merged result plus the per-analyzer sections it came from. */
5539
- interface AnalyzerRun {
5540
- readonly result: AnalyzeResult;
5541
- readonly sections: AnalyzerSection[];
5542
- }
5543
- /**
5544
- * Runs every analyzer whose capability requirements are satisfied.
5545
- *
5546
- * Analyzers are sorted by `id` and run sequentially, so both the call order
5547
- * and the merged output are deterministic regardless of the caller's array
5548
- * order (D5). An analyzer with an unsatisfied requirement is not called: it
5549
- * contributes one `<id>.degraded` proxy metric and one `degraded_capability`
5550
- * evidence item naming the missing capabilities and the device's own reasons.
5551
- * Every analyzer also contributes one {@link AnalyzerSection} to `sections`,
5552
- * in the same id order, so a report can attribute each metric to its source.
5553
- *
5554
- * The returned arrays are new and sorted (`metrics` by `id`, `evidence` by
5555
- * `(kind, window.startNs, id)`). Two analyzers emitting the same metric id
5556
- * make the report ambiguous, so the whole run fails with
5557
- * `DUPLICATE_METRIC_ID` instead of silently keeping one value; the same
5558
- * integrity rule applies to evidence ids (`DUPLICATE_EVIDENCE_ID`). Neither
5559
- * the context nor any analyzer (including its result arrays) is mutated.
5560
- */
5561
- declare function runAnalyzerSections(analyzers: readonly Analyzer[], ctx: AnalyzeContext): Promise<AnalyzerRun>;
5562
- /**
5563
- * Runs every analyzer and returns only the merged result.
5564
- *
5565
- * A thin wrapper over {@link runAnalyzerSections}; existing callers keep the
5566
- * old shape and behavior exactly.
5567
- */
5568
- declare function runAnalyzers(analyzers: readonly Analyzer[], ctx: AnalyzeContext): Promise<AnalyzeResult>;
5569
- /**
5570
- * The analyzers an offline `analyze` run executes by default.
5571
- *
5572
- * Additional analyzers are appended as they are implemented; the function
5573
- * returns a fresh array so callers may add or remove entries without
5574
- * affecting another run.
5575
- */
5576
- declare function defaultAnalyzers(): Analyzer[];
5577
-
5578
5809
  /**
5579
5810
  * Resolves the analyzed package to the identity every analyzer receives.
5580
5811
  *
@@ -5793,131 +6024,6 @@ declare function analyzeHap(bytes: Uint8Array, packageName: string): HapAnalysis
5793
6024
  /** Wrap an analysis as the `static-hap` section the report renderer takes. */
5794
6025
  declare function hapSection(analysis: HapAnalysis): AnalyzerSection;
5795
6026
 
5796
- /** The report document schema. A change to any shape below bumps this. */
5797
- declare const REPORT_SCHEMA_VERSION = 1;
5798
- /** Who produced the report; the version is the CLI package version. */
5799
- interface ReportGenerator {
5800
- name: string;
5801
- version: string;
5802
- }
5803
- /** The scene the report describes. Inputs are copied, never referenced. */
5804
- interface ReportScenario {
5805
- app: {
5806
- packageName: string;
5807
- processNames: string[];
5808
- };
5809
- device: string;
5810
- window: TimeRange;
5811
- /** Capture start from `scene.json`; absent when the scene did not record one. */
5812
- startedAtNs?: number;
5813
- /**
5814
- * The screenshot the bundle carries at `assets/screenshot.png`. Present only
5815
- * when the scene had one, so a renderer can tell "no image" from "an image
5816
- * whose size it was not told".
5817
- */
5818
- screenshot?: {
5819
- width: number;
5820
- height: number;
5821
- };
5822
- }
5823
- /** One analyzer's contribution, ready for rendering. */
5824
- interface ReportSection {
5825
- /** The analyzer id, e.g. `frames`. Also the HTML section anchor. */
5826
- id: string;
5827
- title: string;
5828
- status: 'measured' | 'degraded';
5829
- /** The engine's explanation of why the analyzer was skipped. */
5830
- degradedReason?: string;
5831
- /** Sorted by `id`, as the engine emits them. */
5832
- metrics: Metric[];
5833
- /** Sorted by `(kind, window.startNs, id)`, as the engine emits them. */
5834
- evidence: Evidence[];
5835
- }
5836
- interface ReportTotals {
5837
- metrics: number;
5838
- evidence: number;
5839
- bySeverity: {
5840
- info: number;
5841
- warn: number;
5842
- critical: number;
5843
- };
5844
- measured: number;
5845
- degraded: number;
5846
- }
5847
- /** The complete, versioned report document. */
5848
- interface ReportModel {
5849
- schemaVersion: typeof REPORT_SCHEMA_VERSION;
5850
- generator: ReportGenerator;
5851
- scenario: ReportScenario;
5852
- sections: ReportSection[];
5853
- totals: ReportTotals;
5854
- comparison?: BaselineComparison;
5855
- }
5856
- /** Everything `buildReport` needs; all values are already measured. */
5857
- interface ReportInput {
5858
- generator: ReportGenerator;
5859
- app: AppIdentity;
5860
- device: string;
5861
- window: TimeRange;
5862
- startedAtNs?: number;
5863
- sections: readonly AnalyzerSection[];
5864
- comparison?: BaselineComparison;
5865
- /**
5866
- * The scene's screenshot dimensions, when one was captured. The report copies
5867
- * the file to `assets/screenshot.png` and renders it in the `ui` section; the
5868
- * dimensions are here so the page can state them without decoding the PNG
5869
- * again. Absent means no image was captured, and the page says so instead of
5870
- * pointing at a file that does not exist.
5871
- */
5872
- screenshot?: {
5873
- width: number;
5874
- height: number;
5875
- };
5876
- }
5877
- /** The compact roll-up written to `summary.json`. */
5878
- interface ReportSummary {
5879
- schemaVersion: typeof REPORT_SCHEMA_VERSION;
5880
- app: string;
5881
- device: string;
5882
- window: TimeRange;
5883
- sections: Array<{
5884
- id: string;
5885
- title: string;
5886
- status: 'measured' | 'degraded';
5887
- degradedReason?: string;
5888
- metrics: number;
5889
- evidence: number;
5890
- }>;
5891
- totals: ReportTotals;
5892
- comparison?: Record<DeltaStatus, number>;
5893
- }
5894
- /**
5895
- * Human titles for the analyzers shipped today.
5896
- *
5897
- * An id absent here titles as itself: a new analyzer renders honestly before
5898
- * anyone writes its title, instead of failing the report.
5899
- */
5900
- declare const SECTION_TITLES: Readonly<Record<string, string>>;
5901
- /**
5902
- * Builds the report document from a section-aware engine run.
5903
- *
5904
- * The inputs are copied and sorted, never mutated. Sorting repeats the engine's
5905
- * order so a model assembled by hand (as in tests) is just as deterministic as
5906
- * one produced by `runAnalyzerSections` — the report must be byte-stable (D5)
5907
- * no matter which layer produced its parts.
5908
- */
5909
- declare function buildReport(input: ReportInput): ReportModel;
5910
- /** Collapses the model to its per-section counts and totals. */
5911
- declare function summarizeReport(model: ReportModel): ReportSummary;
5912
- /**
5913
- * The canonical JSON serialization for `report.json` and `summary.json`.
5914
- *
5915
- * Two-space indent plus a trailing newline matches `analyze --json`, so a
5916
- * consumer reads every document in this package the same way.
5917
- */
5918
- declare function renderReportJson(model: ReportModel): string;
5919
- declare function renderSummaryJson(summary: ReportSummary): string;
5920
-
5921
6027
  /**
5922
6028
  * One CSV row per metric, in model order (sections by id, metrics by id).
5923
6029
  *
@@ -6001,4 +6107,4 @@ interface FlamegraphPageInput {
6001
6107
  */
6002
6108
  declare function renderFlamegraphHtml(input: FlamegraphPageInput): string;
6003
6109
 
6004
- export { ANIMATION_BANDS, type ActionContext, type ActionDevice, type ActionOutcome, type ActiveAlloc, type AnalyzeContext, type AnalyzeResult, type Analyzer, type AnalyzerRun, type AnalyzerSection, type AnimationAnalysis, type AnimationLabel, type AnimationSeverity, type AppIdentity, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, CATEGORY_EXTENSIONS, CATEGORY_MAX_BYTES, COLLECTOR_NAMES, type CallchainSample, type CallstackEvent, type CallstackEventWithArgs, CallstackQuery, type CapabilityId, type CapabilityInputs, CapabilityMatrix, type CapabilityState, type CaseLoad, type CategoryTotal, type CollectOptions, type CollectSession, type Collector, type CollectorName, type CompiledRule, type ComponentReuse, ComponentReuseAnalyzer, type ConnectOptions, type ContentPattern, type CreateEmulatorRequest, DEFAULT_HILOG_RULES, DEFAULT_QUERY_LIMIT, DEVICE_PERF_PATH, DEVICE_SCREENSHOT_PATH, DEVICE_UI_PATH, type DeltaStatus, type DepGraph, type DepGraphEdge, type DepGraphFile, Device, type DeviceDeps, type DeviceIdentity, DeviceNotFoundError, type DiscoveredCase, type DrillDownHandle, type DuplicateGroup, EXCLUDE_PATTERNS, EmptyFrameAnalyzer, type EmptyFrameFilter, type EmulatorBackend, EmulatorClient, type EmulatorClientOptions, EmulatorCommandError, type EmulatorImage, EmulatorImageMissingError, type EmulatorInstance, EmulatorLifecycle, type EmulatorLifecycleOptions, EmulatorNotFoundError, type EmulatorStartResult, type EmulatorStopResult, type Env, type Evidence, type EvidenceKind, type ExpectPresent, type ExpectationOutcome, FLAMEGRAPH_FILES, FPS_COMMAND, FTRACE_CATEGORIES, FaultTreeAnalyzer, type FaultTreeSignals, type Fidelity, type FileCategory, type FileRule, FlamegraphAnalyzer, type FlamegraphPageInput, type FoldedStack, type FpsBucket, type FpsWindow, type Frame, FrameAnalyzer, type FrameFlag, FrameLoadAnalyzer, FrameLoadIndex, type FrameLoadIndexInput, type FrameLoadThread, FrameQuery, type FrameStats, type FrameType, type FtraceOptions, GEOMETRY_TOLERANCE_PX, GcAnalyzer, type GcSignals, type Gesture, GestureDriver, type GestureResult, HILOG_COMMAND, HIPROFILER_PLUGIN_NAMES, HITCH_COMMAND, HITRACE_DEFAULT_CATEGORIES, type HapAnalysis, type HapPackage, type HarEdge, Hdc, HdcNotFoundError, type HdcOptions, type HdcResult, type HdcSlice, type HdcTarget, type HidumperCapture, HidumperCollector, type HidumperSnapshot, HilogAnalyzer, HilogCollector, type HilogLevel, type HilogLine, type HilogMatch, type HilogParseOptions, type HilogRule, type HiperfCapture, type HiperfCollectOptions, HiperfCollector, type HiprofilerCollectOptions, type HiprofilerCollectRequest, HiprofilerCollector, type HiprofilerConfigOptions, type HiprofilerPlugin, type HiprofilerPluginName, HitraceCollector, IGNORED_ATTRIBUTES, type ImageComparison, IngestError, InstantQuery, type InventoryFile, type JsheapCapture, JsheapCollector, MAX_QUERY_LIMIT, METRIC_DIRECTIONS, MIN_BUFFER_PAGES, MIN_HASH_PIXELS, MemMeasureQuery, MemoryAnalyzer, MemoryMeasureAnalyzer, type MemoryPluginOptions, type MetadataPattern, type Metric, type MetricDelta, type MetricDirection, type MetricUnit, type ModuleDecl, type NamedQueryDefinition, type NamedQueryInfo, type NamedQueryResult, type NativeCategory, type NativeEventKind, type NativeHookEvent, type NativeHookFrame, NativeHookQuery, type NativeHookStatistic, NativeMemoryAnalyzer, type NativeMemoryResult, type NativeNames, type NativeTimelineBucket, type NativehookOptions, OhosPerfError, type OptimizationPotential, type OversizedFile, PARITY_ROWS, PLANE_A_PLUGINS, type ParityRow, type ParityStatus, type PerfCallchain, type PerfFileAttribution, type PerfFunction, type PerfLeafAttribution, PerfQuery, type PerfSampleRow, type PerfThread, type PixelOnlyChange, type ProbeResult, type ProbeRunner, type ProbeSnapshot, type ProcessInfo, type ProcessMeasure, type ProcessMeasureFilter, ProcessQuery, ProcfsCollector, type ProcfsSample, type ProcfsStatus, type Provenance, type QueryArgument, type QueryContext, type QueryHandle, REPORT_SCHEMA_VERSION, type Rect, type RedundancyLevel, type RedundancyType, RedundantFileAnalyzer, type RedundantFileEntry, type RedundantFileReport, type RedundantThreadPattern, type RedundantThreadsSummary, type RegionPixelChange, RenderAnalyzer, type ReportGenerator, type ReportInput, type ReportModel, type ReportScenario, type ReportSection, type ReportSummary, type ReportTotals, type RgbaImage, RsSkipAnalyzer, type RsSkipFrame, type RsSkipResult, type RsSkipTraceMethod, type RuleMatch, type RuleMatchKind, type RunOptions, type RunResult, type RunStepResult, type RunnerCollectOptions, type RunnerDevice, SECTION_TITLES, type Scenario, type ScenarioAction, ScenarioRunner, type ScenarioStep, Scene, type SceneLayout, type SceneMetadata, type SceneStep, type SceneStepRef, type ScenesComparison, SchedQuery, type SchedSlice, type ScreenshotCapture, ScreenshotCollector, type Selector, type SelectorRect, type SmapsRollup, StartupAnalyzer, StartupQuery, type StartupRecord, type StepCapture, type StepComparison, type StepExpectation, type StepStatus, Streamer, StreamerNotFoundError, type StreamerOptions, type SymbolStat, SymbolsAnalyzer, TECH_RULES, type TechRule, type ThreadAnalysis, type ThreadAnalysisSummary, ThreadAnalyzer, type ThreadInfo, ThreadQuery, type ThreadState, ThreadStateQuery, type ThreadWakeupResult, type ThreadWakeupThread, type TimeRange, type TimingCycle, type TraceCollectOptions, UI_DIFF_FILES, UiAnalyzer, type UiCompareOptions, type UiDiff, type UiDiffSide, type UiNode, type UiTreeDiff, type UiTreeDifference, UitestCollector, type UnmeasuredRegion, type UnreleasedRow, type VsyncAnalysis, VsyncAnalyzer, type VsyncPeriod, type VsyncPeriodKind, type VsyncSeverity, type WakeupEvent, type WindowHitches, type ZipArchive, type ZipEntry, aggregateUnreleased, analyseAnimations, analyzeHap, analyzeThreadWakeup, animationSeverity, buildDepGraph, buildHiprofilerConfig, buildInventory, buildMatrix, buildNativeTimeline, buildReport, categorize, classifyNativePath, compareImages, compareRegion, compareResults, compareSceneDirs, compareScenes, compileRules, computeBinderAnalysis, computeComponentReuse, computeFaultTree, computeFpsWindows, computeGc, computeRsSkip, computeThreadAnalysis, computeVsyncAnomalies, connect, createSceneLayout, cropRegion, decodePng, defaultAnalyzers, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hiperfRecordCommand, ingestScene, isUnresolvedSymbol, isZip, loadCases, lookupQuery, markRegions, matchHapRules, matchRules, matchSelector, memoryPlugin, metric, nativeEventKind, nativehookPlugin, nodeIdentity, openDb, openZip, pairNativeMemory, paritySummary, parseBounds, parseFpsCounts, parseHilogLine, parseHilogText, parseHiperfSummary, parseHitches, parseProcfsStatus, parseRedundantFile, parseScenario, parseSelector, parseSmapsRollup, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderEvidenceCsv, renderFlamegraphHtml, renderFlamegraphSvg, renderMetricsCsv, renderReportHtml, renderReportJson, renderReportXlsx, renderScenesComparison, renderSummaryJson, renderUiDiffHtml, resolveAppIdentity, resolveAppIpids, resolveQueryLimit, resolveSelector, round2HalfEven, runAnalyzerSections, runAnalyzers, runDrillDown, runNamedQuery, runProbe, sortSteps, summarizeReport, tableRowCounts, unknownQueryError, validateRules, writeProcfsSamples, writeRunFiles, writeSceneMetadata, xpowerPlugin };
6110
+ export { ANIMATION_BANDS, type ActionContext, type ActionDevice, type ActionOutcome, type ActiveAlloc, type AnalyzeContext, type AnalyzeResult, type Analyzer, type AnalyzerRun, type AnalyzerSection, type AnimationAnalysis, type AnimationLabel, type AnimationSeverity, type AppIdentity, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, CATEGORY_EXTENSIONS, CATEGORY_MAX_BYTES, COLLECTOR_NAMES, type CallchainSample, type CallstackEvent, type CallstackEventWithArgs, CallstackQuery, type CapabilityId, type CapabilityInputs, CapabilityMatrix, type CapabilityState, type CaseLoad, type CategoryTotal, type CollectOptions, type CollectSession, type Collector, type CollectorName, type CompiledRule, type ComponentReuse, ComponentReuseAnalyzer, type ConnectOptions, type ContentPattern, type CreateEmulatorRequest, DEFAULT_HILOG_RULES, DEFAULT_QUERY_LIMIT, DEVICE_PERF_PATH, DEVICE_SCREENSHOT_PATH, DEVICE_UI_PATH, type DeltaStatus, type DepGraph, type DepGraphEdge, type DepGraphFile, Device, type DeviceDeps, type DeviceIdentity, DeviceNotFoundError, type DiscoveredCase, type DrillDownHandle, type DuplicateGroup, EXCLUDE_PATTERNS, EmptyFrameAnalyzer, type EmptyFrameFilter, type EmulatorBackend, EmulatorClient, type EmulatorClientOptions, EmulatorCommandError, type EmulatorImage, EmulatorImageMissingError, type EmulatorInstance, EmulatorLifecycle, type EmulatorLifecycleOptions, EmulatorNotFoundError, type EmulatorStartResult, type EmulatorStopResult, type Env, type Evidence, type EvidenceKind, type ExpectPresent, type ExpectationOutcome, FLAMEGRAPH_FILES, FPS_COMMAND, FTRACE_CATEGORIES, FaultTreeAnalyzer, type FaultTreeSignals, type Fidelity, type FileCategory, type FileRule, FlamegraphAnalyzer, type FlamegraphPageInput, type FoldedStack, type FpsBucket, type FpsWindow, type Frame, FrameAnalyzer, type FrameFlag, FrameLoadAnalyzer, FrameLoadIndex, type FrameLoadIndexInput, type FrameLoadThread, FrameQuery, type FrameStats, type FrameType, type FtraceOptions, GEOMETRY_TOLERANCE_PX, GcAnalyzer, type GcSignals, type Gesture, GestureDriver, type GestureResult, HILOG_COMMAND, HIPROFILER_PLUGIN_NAMES, HITCH_COMMAND, HITRACE_DEFAULT_CATEGORIES, type HapAnalysis, type HapPackage, type HarEdge, Hdc, HdcNotFoundError, type HdcOptions, type HdcResult, type HdcSlice, type HdcTarget, type HidumperCapture, HidumperCollector, type HidumperSnapshot, HilogAnalyzer, HilogCollector, type HilogLevel, type HilogLine, type HilogMatch, type HilogParseOptions, type HilogRule, type HiperfCapture, type HiperfCollectOptions, HiperfCollector, type HiprofilerCollectOptions, type HiprofilerCollectRequest, HiprofilerCollector, type HiprofilerConfigOptions, type HiprofilerPlugin, type HiprofilerPluginName, HitraceCollector, IGNORED_ATTRIBUTES, type ImageComparison, IngestError, InstantQuery, type InventoryFile, type JsheapCapture, JsheapCollector, MAX_QUERY_LIMIT, METRIC_DIRECTIONS, MIN_BUFFER_PAGES, MIN_HASH_PIXELS, MemMeasureQuery, MemoryAnalyzer, MemoryMeasureAnalyzer, type MemoryPluginOptions, type MetadataPattern, type Metric, type MetricDelta, type MetricDirection, type MetricUnit, type ModuleDecl, type NamedQueryDefinition, type NamedQueryInfo, type NamedQueryResult, type NativeCategory, type NativeEventKind, type NativeHookEvent, type NativeHookFrame, NativeHookQuery, type NativeHookStatistic, NativeMemoryAnalyzer, type NativeMemoryResult, type NativeNames, type NativeTimelineBucket, type NativehookOptions, OhosPerfError, type OptimizationPotential, type OversizedFile, PARITY_ROWS, PLANE_A_PLUGINS, type ParityRow, type ParityStatus, type PerfCallchain, type PerfFileAttribution, type PerfFunction, type PerfLeafAttribution, PerfQuery, type PerfSampleRow, type PerfThread, type PixelOnlyChange, type ProbeResult, type ProbeRunner, type ProbeSnapshot, type ProcessInfo, type ProcessMeasure, type ProcessMeasureFilter, ProcessQuery, ProcfsCollector, type ProcfsSample, type ProcfsStatus, type Provenance, type QueryArgument, type QueryContext, type QueryHandle, REPORT_SCHEMA_VERSION, type Rect, type RedundancyLevel, type RedundancyType, RedundantFileAnalyzer, type RedundantFileEntry, type RedundantFileReport, type RedundantThreadPattern, type RedundantThreadsSummary, type RegionPixelChange, RenderAnalyzer, type ReportGenerator, type ReportInput, type ReportModel, type ReportScenario, type ReportSection, type ReportSummary, type ReportTotals, type RgbaImage, RsSkipAnalyzer, type RsSkipFrame, type RsSkipResult, type RsSkipTraceMethod, type RuleMatch, type RuleMatchKind, type RunOptions, type RunResult, type RunStepResult, type RunnerCollectOptions, type RunnerDevice, SECTION_TITLES, type Scenario, type ScenarioAction, ScenarioRunner, type ScenarioStep, Scene, type SceneLayout, type SceneMetadata, type SceneStep, type SceneStepRef, type ScenesComparison, SchedQuery, type SchedSlice, type ScreenshotCapture, ScreenshotCollector, type Selector, type SelectorRect, type SmapsRollup, StartupAnalyzer, StartupQuery, type StartupRecord, type StepCapture, type StepComparison, type StepExpectation, type StepStatus, Streamer, StreamerNotFoundError, type StreamerOptions, type SymbolStat, SymbolsAnalyzer, TECH_RULES, type TechRule, type ThreadAnalysis, type ThreadAnalysisSummary, ThreadAnalyzer, type ThreadInfo, ThreadQuery, type ThreadState, ThreadStateQuery, type ThreadWakeupResult, type ThreadWakeupThread, type TimeRange, type TimingCycle, type TraceCollectOptions, type Trend, type TrendOrder, type TrendPoint, type TrendRun, type TrendSeries, UI_DIFF_FILES, UiAnalyzer, type UiCompareOptions, type UiDiff, type UiDiffSide, type UiNode, type UiTreeDiff, type UiTreeDifference, UitestCollector, type UnmeasuredRegion, type UnreleasedRow, type VsyncAnalysis, VsyncAnalyzer, type VsyncPeriod, type VsyncPeriodKind, type VsyncSeverity, type WakeupEvent, type WindowHitches, type ZipArchive, type ZipEntry, aggregateUnreleased, analyseAnimations, analyzeHap, analyzeThreadWakeup, animationSeverity, buildDepGraph, buildHiprofilerConfig, buildInventory, buildMatrix, buildNativeTimeline, buildReport, buildTrend, categorize, classifyNativePath, compareImages, compareRegion, compareResults, compareSceneDirs, compareScenes, compileRules, computeBinderAnalysis, computeComponentReuse, computeFaultTree, computeFpsWindows, computeGc, computeRsSkip, computeThreadAnalysis, computeVsyncAnomalies, connect, createSceneLayout, cropRegion, decodePng, defaultAnalyzers, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hiperfRecordCommand, ingestScene, isUnresolvedSymbol, isZip, loadCases, lookupQuery, markRegions, matchHapRules, matchRules, matchSelector, memoryPlugin, metric, nativeEventKind, nativehookPlugin, nodeIdentity, openDb, openZip, pairNativeMemory, paritySummary, parseBounds, parseFpsCounts, parseHilogLine, parseHilogText, parseHiperfSummary, parseHitches, parseProcfsStatus, parseRedundantFile, parseScenario, parseSelector, parseSmapsRollup, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderEvidenceCsv, renderFlamegraphHtml, renderFlamegraphSvg, renderMetricsCsv, renderReportHtml, renderReportJson, renderReportXlsx, renderScenesComparison, renderSummaryJson, renderTrendHtml, renderTrendJson, renderUiDiffHtml, resolveAppIdentity, resolveAppIpids, resolveQueryLimit, resolveSelector, round2HalfEven, runAnalyzerSections, runAnalyzers, runDrillDown, runNamedQuery, runProbe, sortSteps, summarizeReport, tableRowCounts, trendRunFromReport, unknownQueryError, validateRules, writeProcfsSamples, writeRunFiles, writeSceneMetadata, xpowerPlugin };
package/dist/index.js CHANGED
@@ -6354,7 +6354,7 @@ var PARITY_ROWS = [
6354
6354
  row: 33,
6355
6355
  name: "Report bundle, dashboard and update",
6356
6356
  status: "partial",
6357
- 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."
6357
+ reason: "The typed report model, offline HTML, JSON/CSV/XLSX, baseline comparison and the multi-run trend page are ported; re-rendering a bundle from its saved inputs is not."
6358
6358
  },
6359
6359
  {
6360
6360
  row: 34,
@@ -6365,8 +6365,8 @@ var PARITY_ROWS = [
6365
6365
  {
6366
6366
  row: 35,
6367
6367
  name: "Report comparison",
6368
- status: "partial",
6369
- reason: "Typed comparison and the scene+step pivot are ported; aggregating more than two reports into one trend is not."
6368
+ status: "ported",
6369
+ reason: ""
6370
6370
  }
6371
6371
  ];
6372
6372
  function paritySummary() {
@@ -6754,6 +6754,228 @@ function sortSteps(steps) {
6754
6754
  return [...steps].sort(byStepId);
6755
6755
  }
6756
6756
 
6757
+ // src/report/trend.ts
6758
+ function byString(a, b) {
6759
+ return a < b ? -1 : a > b ? 1 : 0;
6760
+ }
6761
+ function round32(value) {
6762
+ return Math.round(value * 1e3) / 1e3;
6763
+ }
6764
+ function buildTrend(runs) {
6765
+ if (runs.length < 2) {
6766
+ throw new Error("buildTrend: a trend needs at least two runs");
6767
+ }
6768
+ const seen = /* @__PURE__ */ new Set();
6769
+ for (const run of runs) {
6770
+ if (seen.has(run.label)) {
6771
+ throw new Error(`buildTrend: duplicate run label "${run.label}"`);
6772
+ }
6773
+ seen.add(run.label);
6774
+ }
6775
+ const apps = [...new Set(runs.map((run) => run.app))].sort();
6776
+ if (apps.length > 1) {
6777
+ throw new Error(
6778
+ `buildTrend: the runs measure different apps (${apps.join(", ")}); a trend is only comparable within one app`
6779
+ );
6780
+ }
6781
+ const timed = runs.every((run) => run.startedAtNs !== void 0);
6782
+ const orderedBy = timed ? "startedAtNs" : "argument";
6783
+ const ordered2 = timed ? [...runs].sort((a, b) => a.startedAtNs - b.startedAtNs) : [...runs];
6784
+ const ids = [...new Set(runs.flatMap((run) => run.metrics.map((metric2) => metric2.id)))].sort();
6785
+ const series = ids.map((id) => {
6786
+ const points = [];
6787
+ const fidelities = /* @__PURE__ */ new Set();
6788
+ let unit;
6789
+ for (const run of ordered2) {
6790
+ const metric2 = run.metrics.find((candidate) => candidate.id === id);
6791
+ if (metric2 === void 0 || metric2.degraded !== void 0) {
6792
+ points.push({ label: run.label, value: null });
6793
+ continue;
6794
+ }
6795
+ unit ??= metric2.unit;
6796
+ fidelities.add(metric2.fidelity);
6797
+ points.push({ label: run.label, value: metric2.value, fidelity: metric2.fidelity });
6798
+ }
6799
+ const measuredPoints = points.filter(
6800
+ (point) => point.value !== null && typeof point.value === "number"
6801
+ );
6802
+ const first = measuredPoints[0];
6803
+ const last = measuredPoints[measuredPoints.length - 1];
6804
+ const numeric = first === void 0 || last === void 0 || measuredPoints.length < 2 ? void 0 : { first: first.value, last: last.value };
6805
+ const delta2 = numeric === void 0 ? void 0 : numeric.last - numeric.first;
6806
+ const deltaPct = numeric === void 0 || numeric.first === 0 ? void 0 : round32((numeric.last - numeric.first) / Math.abs(numeric.first) * 100);
6807
+ const direction = METRIC_DIRECTIONS[id];
6808
+ let status;
6809
+ if (delta2 !== void 0 && direction !== void 0) {
6810
+ status = delta2 === 0 ? "unchanged" : direction === "lower" ? delta2 < 0 ? "improved" : "regressed" : delta2 > 0 ? "improved" : "regressed";
6811
+ }
6812
+ return {
6813
+ id,
6814
+ unit: unit ?? "none",
6815
+ points,
6816
+ measured: measuredPoints.length,
6817
+ ...delta2 === void 0 ? {} : { delta: delta2 },
6818
+ ...deltaPct === void 0 ? {} : { deltaPct },
6819
+ ...status === void 0 ? {} : { status },
6820
+ fidelities: [...fidelities].sort(byString)
6821
+ };
6822
+ });
6823
+ return { runs: ordered2, orderedBy, series };
6824
+ }
6825
+ function renderTrendJson(trend) {
6826
+ return `${JSON.stringify(trend, null, 2)}
6827
+ `;
6828
+ }
6829
+ function trendRunFromReport(label2, model) {
6830
+ return {
6831
+ label: label2,
6832
+ app: model.scenario.app.packageName,
6833
+ device: model.scenario.device,
6834
+ ...model.scenario.startedAtNs === void 0 ? {} : { startedAtNs: model.scenario.startedAtNs },
6835
+ metrics: model.sections.flatMap((section) => section.metrics)
6836
+ };
6837
+ }
6838
+ var STYLE2 = `
6839
+ :root { color-scheme: light; }
6840
+ * { box-sizing: border-box; }
6841
+ body { margin: 0; padding: 2rem 1.25rem 4rem; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: #1c1f24; background: #f6f7f9; }
6842
+ main { max-width: 1100px; margin: 0 auto; }
6843
+ h1 { margin: 0 0 .25rem; font-size: 1.75rem; letter-spacing: -.02em; }
6844
+ h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
6845
+ p { margin: .35rem 0; }
6846
+ code { font: 13px/1.4 ui-monospace, "Cascadia Code", Consolas, monospace; }
6847
+ .subtitle { color: #47505c; }
6848
+ .meta { color: #6b7480; font-size: .85rem; }
6849
+ .card { background: #fff; border: 1px solid #e2e5e9; border-radius: 8px; padding: 1rem 1.1rem; margin: 0 0 1rem; }
6850
+ table { width: 100%; border-collapse: collapse; font-size: .88rem; }
6851
+ th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #eef0f2; vertical-align: top; }
6852
+ th { color: #5b6470; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
6853
+ td.num { text-align: right; font-variant-numeric: tabular-nums; }
6854
+ .dim { color: #6b7480; }
6855
+ .chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: .08rem .45rem; border-radius: 999px; background: #eef1f4; text-transform: lowercase; }
6856
+ .chip.improved { background: #ecfdf3; color: #166534; }
6857
+ .chip.regressed { background: #fef2f2; color: #b91c1c; }
6858
+ .chip.unchanged { background: #eef1f4; color: #374151; }
6859
+ .chip.mixed { background: #fff7ed; color: #9a3412; }
6860
+ svg.spark { display: block; width: 100%; height: 90px; overflow: visible; }
6861
+ svg.spark polyline { fill: none; stroke: #2563eb; stroke-width: 1.5; }
6862
+ svg.spark circle { fill: #2563eb; }
6863
+ svg.spark .gap { fill: none; stroke: #9ca3af; stroke-dasharray: 2 3; stroke-width: 1; }
6864
+ footer { margin-top: 2rem; color: #6b7480; font-size: .8rem; }
6865
+ `.trim();
6866
+ function cellText(point) {
6867
+ return point.value === null ? "\u2014" : String(point.value);
6868
+ }
6869
+ function sparkline(series) {
6870
+ const width = 100;
6871
+ const height = 100;
6872
+ const pad = 4;
6873
+ const count = series.points.length;
6874
+ const numeric = series.points.map((point) => typeof point.value === "number" ? point.value : null);
6875
+ const values = numeric.filter((value) => value !== null);
6876
+ if (values.length < 2) return "";
6877
+ let min = Math.min(...values);
6878
+ let max = Math.max(...values);
6879
+ if (min === max) {
6880
+ min -= 1;
6881
+ max += 1;
6882
+ }
6883
+ const x = (index) => count === 1 ? width / 2 : pad + index * (width - pad * 2) / (count - 1);
6884
+ const y = (value) => height - pad - (value - min) / (max - min) * (height - pad * 2);
6885
+ const segments2 = [];
6886
+ let current = [];
6887
+ for (let index = 0; index < count; index += 1) {
6888
+ const value = numeric[index];
6889
+ if (value === null) {
6890
+ if (current.length > 0) segments2.push(current.join(" "));
6891
+ current = [];
6892
+ continue;
6893
+ }
6894
+ current.push(`${x(index).toFixed(2)},${y(value).toFixed(2)}`);
6895
+ }
6896
+ if (current.length > 0) segments2.push(current.join(" "));
6897
+ const lines = segments2.map(
6898
+ (segment) => `<polyline points="${segment}"/>`
6899
+ );
6900
+ const dots = series.points.map(
6901
+ (point, index) => typeof point.value === "number" ? `<circle cx="${x(index).toFixed(2)}" cy="${y(point.value).toFixed(2)}" r="1.6"/>` : ""
6902
+ ).filter((dot) => dot !== "");
6903
+ return `<svg class="spark" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none" role="img" aria-label="${escapeHtml(series.id)} across ${count} runs">${lines.join("")}${dots.join("")}</svg>`;
6904
+ }
6905
+ function renderTrendHtml(trend) {
6906
+ const orderNote = trend.orderedBy === "startedAtNs" ? "ordered by capture start time" : "in argument order (a run has no capture start time, so time order was not assumed)";
6907
+ const runRows = trend.runs.map(
6908
+ (run) => [
6909
+ "<tr>",
6910
+ `<td><code>${escapeHtml(run.label)}</code></td>`,
6911
+ `<td>${escapeHtml(run.app)}</td>`,
6912
+ `<td>${escapeHtml(run.device)}</td>`,
6913
+ `<td class="num">${run.startedAtNs === void 0 ? "\u2014" : escapeHtml(String(run.startedAtNs))}</td>`,
6914
+ `<td class="num">${run.metrics.length}</td>`,
6915
+ "</tr>"
6916
+ ].join("\n")
6917
+ );
6918
+ const seriesRows = trend.series.map((series) => {
6919
+ const mixed = series.fidelities.length > 1;
6920
+ const status = series.status === void 0 ? '<span class="dim">\u2014</span>' : `<span class="chip ${series.status}">${escapeHtml(series.status)}</span>`;
6921
+ const delta2 = series.delta === void 0 ? '<span class="dim">\u2014</span>' : escapeHtml(String(series.delta));
6922
+ const pct = series.deltaPct === void 0 ? '<span class="dim">\u2014</span>' : escapeHtml(`${series.deltaPct}%`);
6923
+ const spark = sparkline(series);
6924
+ return [
6925
+ "<tr>",
6926
+ `<td><code>${escapeHtml(series.id)}</code><div class="dim">${series.measured} of ${series.points.length} runs measured</div></td>`,
6927
+ `<td>${spark === "" ? '<span class="dim">not measured</span>' : spark}</td>`,
6928
+ ...series.points.map((point) => `<td class="num">${escapeHtml(cellText(point))}</td>`),
6929
+ `<td>${escapeHtml(series.unit)}</td>`,
6930
+ `<td class="num">${delta2}</td>`,
6931
+ `<td class="num">${pct}</td>`,
6932
+ `<td>${status}</td>`,
6933
+ `<td class="${mixed ? "chip mixed" : "dim"}">${escapeHtml(series.fidelities.join(", ") || "\u2014")}</td>`,
6934
+ "</tr>"
6935
+ ].join("\n");
6936
+ });
6937
+ return [
6938
+ "<!doctype html>",
6939
+ '<html lang="en">',
6940
+ "<head>",
6941
+ '<meta charset="utf-8">',
6942
+ '<meta name="viewport" content="width=device-width, initial-scale=1">',
6943
+ `<title>ohos-perf trend \u2014 ${escapeHtml(trend.runs[0]?.app ?? "")}</title>`,
6944
+ `<style>${STYLE2}</style>`,
6945
+ "</head>",
6946
+ "<body>",
6947
+ "<main>",
6948
+ "<header>",
6949
+ "<h1>ohos-perf trend</h1>",
6950
+ `<p class="subtitle">${escapeHtml(trend.runs[0]?.app ?? "")} \xB7 ${trend.runs.length} runs \xB7 ${trend.series.length} metrics</p>`,
6951
+ `<p class="meta">${escapeHtml(orderNote)}</p>`,
6952
+ "</header>",
6953
+ '<section class="card">',
6954
+ "<h2>Runs</h2>",
6955
+ "<table>",
6956
+ "<thead><tr><th>Run</th><th>App</th><th>Device</th><th>Started at (ns)</th><th>Metrics</th></tr></thead>",
6957
+ "<tbody>",
6958
+ ...runRows,
6959
+ "</tbody>",
6960
+ "</table>",
6961
+ "</section>",
6962
+ '<section class="card">',
6963
+ "<h2>Metrics</h2>",
6964
+ "<table>",
6965
+ "<thead><tr><th>Metric</th><th>Trend</th>" + trend.runs.map((run) => `<th>${escapeHtml(run.label)}</th>`).join("") + "<th>Unit</th><th>Delta</th><th>%</th><th>Status</th><th>Fidelity</th></tr></thead>",
6966
+ "<tbody>",
6967
+ ...seriesRows,
6968
+ "</tbody>",
6969
+ "</table>",
6970
+ "</section>",
6971
+ "<footer>Generated from measured run data. A dash is a run that did not emit the metric, never a zero. No scripts, no external resources.</footer>",
6972
+ "</main>",
6973
+ "</body>",
6974
+ "</html>",
6975
+ ""
6976
+ ].join("\n");
6977
+ }
6978
+
6757
6979
  // src/scenario/actions.ts
6758
6980
  var MAX_SCROLLS = 5;
6759
6981
  var DEFAULT_DISTANCE = 40;
@@ -14169,7 +14391,7 @@ var StartupAnalyzer = class {
14169
14391
 
14170
14392
  // src/analyze/hilog.ts
14171
14393
  var SAMPLE_LIMIT = 5;
14172
- function byString(a, b) {
14394
+ function byString2(a, b) {
14173
14395
  return a < b ? -1 : a > b ? 1 : 0;
14174
14396
  }
14175
14397
  function appProcessName8(ctx) {
@@ -14279,7 +14501,7 @@ var HilogAnalyzer = class {
14279
14501
  window: ctx.window
14280
14502
  })
14281
14503
  ];
14282
- metrics.sort((a, b) => byString(a.id, b.id));
14504
+ metrics.sort((a, b) => byString2(a.id, b.id));
14283
14505
  const process2 = appProcessName8(ctx);
14284
14506
  const items = byRule.filter((rule) => rule.matches.length > 0).map((rule) => {
14285
14507
  const first = rule.matches[0];
@@ -14331,7 +14553,7 @@ function byEvidenceOrder9(a, b) {
14331
14553
  // src/analyze/ui.ts
14332
14554
  var NO_SCREENSHOT = "no screenshot in this scene";
14333
14555
  var NO_TREE = "no UI tree in this scene";
14334
- function byString2(a, b) {
14556
+ function byString3(a, b) {
14335
14557
  return a < b ? -1 : a > b ? 1 : 0;
14336
14558
  }
14337
14559
  function appProcessName9(ctx) {
@@ -14488,7 +14710,7 @@ var UiAnalyzer = class {
14488
14710
  ...treeMetrics(ctx, nodes),
14489
14711
  ...imageMetrics(ctx, image, ctx.screenshotError ?? NO_SCREENSHOT)
14490
14712
  ];
14491
- metrics.sort((a, b) => byString2(a.id, b.id));
14713
+ metrics.sort((a, b) => byString3(a.id, b.id));
14492
14714
  const items = nodes === void 0 ? [] : (() => {
14493
14715
  const stats = treeStats(nodes);
14494
14716
  return [evidence({
@@ -16096,7 +16318,7 @@ var SymbolsAnalyzer = class {
16096
16318
  const unresolvedWeight = unresolved.reduce((sum, row2) => sum + row2.samples, 0);
16097
16319
  const total = resolvedWeight + unresolvedWeight;
16098
16320
  const hasSymbolTable = ctx.perf.hasSymbolTable();
16099
- const files = [...new Set(resolved.map((row2) => row2.filePath).filter((path) => path !== ""))].sort(byString3);
16321
+ const files = [...new Set(resolved.map((row2) => row2.filePath).filter((path) => path !== ""))].sort(byString4);
16100
16322
  const top = resolved[0];
16101
16323
  const prov = {
16102
16324
  collector: "hiperf",
@@ -16224,7 +16446,7 @@ function share2(samples, total) {
16224
16446
  function formatShare(value) {
16225
16447
  return `${value}%`;
16226
16448
  }
16227
- function byString3(a, b) {
16449
+ function byString4(a, b) {
16228
16450
  return a < b ? -1 : a > b ? 1 : 0;
16229
16451
  }
16230
16452
  function byMetricId14(a, b) {
@@ -17144,7 +17366,7 @@ import { createHash as createHash2 } from "node:crypto";
17144
17366
  var OFFLINE_WINDOW = { startNs: 0, endNs: 0 };
17145
17367
  var LARGEST_COUNT = 10;
17146
17368
  var EXPLAIN_PATHS = 5;
17147
- function byString4(a, b) {
17369
+ function byString5(a, b) {
17148
17370
  return a < b ? -1 : a > b ? 1 : 0;
17149
17371
  }
17150
17372
  function sha256(bytes) {
@@ -17196,7 +17418,7 @@ function findDuplicates(archive, inventory) {
17196
17418
  const groups = [];
17197
17419
  for (const [hash, files] of byHash) {
17198
17420
  if (files.length < 2) continue;
17199
- const sorted = [...files].sort((a, b) => byString4(a.path, b.path));
17421
+ const sorted = [...files].sort((a, b) => byString5(a.path, b.path));
17200
17422
  const size = sorted[0].size;
17201
17423
  groups.push({
17202
17424
  sha256: hash,
@@ -17206,7 +17428,7 @@ function findDuplicates(archive, inventory) {
17206
17428
  paths: sorted.map((file) => file.path)
17207
17429
  });
17208
17430
  }
17209
- return groups.sort((a, b) => byString4(a.sha256, b.sha256));
17431
+ return groups.sort((a, b) => byString5(a.sha256, b.sha256));
17210
17432
  }
17211
17433
  function findOversized(inventory) {
17212
17434
  return inventory.filter((file) => file.size > CATEGORY_MAX_BYTES[file.category]).map((file) => ({
@@ -17214,7 +17436,7 @@ function findOversized(inventory) {
17214
17436
  category: file.category,
17215
17437
  size: file.size,
17216
17438
  threshold: CATEGORY_MAX_BYTES[file.category]
17217
- })).sort((a, b) => b.size - a.size || byString4(a.path, b.path));
17439
+ })).sort((a, b) => b.size - a.size || byString5(a.path, b.path));
17218
17440
  }
17219
17441
  function categoryTotals(inventory) {
17220
17442
  const totals = /* @__PURE__ */ new Map();
@@ -17227,7 +17449,7 @@ function categoryTotals(inventory) {
17227
17449
  compressedSize: (current?.compressedSize ?? 0) + file.compressedSize
17228
17450
  });
17229
17451
  }
17230
- return [...totals.values()].sort((a, b) => byString4(a.name, b.name));
17452
+ return [...totals.values()].sort((a, b) => byString5(a.name, b.name));
17231
17453
  }
17232
17454
  function listPaths(paths) {
17233
17455
  const shown = paths.slice(0, EXPLAIN_PATHS).join(", ");
@@ -17319,7 +17541,7 @@ function buildMetrics(analysis) {
17319
17541
  window: OFFLINE_WINDOW
17320
17542
  }));
17321
17543
  }
17322
- return metrics.sort((a, b) => byString4(a.id, b.id));
17544
+ return metrics.sort((a, b) => byString5(a.id, b.id));
17323
17545
  }
17324
17546
  function buildEvidence(analysis) {
17325
17547
  const subject = { process: analysis.package.bundleName === "" ? analysis.package.name : analysis.package.bundleName };
@@ -17371,7 +17593,7 @@ function buildEvidence(analysis) {
17371
17593
  key: file.path
17372
17594
  }));
17373
17595
  }
17374
- return items.sort((a, b) => byString4(a.kind, b.kind) || a.window.startNs - b.window.startNs || byString4(a.id, b.id));
17596
+ return items.sort((a, b) => byString5(a.kind, b.kind) || a.window.startNs - b.window.startNs || byString5(a.id, b.id));
17375
17597
  }
17376
17598
  function analyzeHap(bytes, packageName) {
17377
17599
  const archive = openZip(bytes);
@@ -17387,7 +17609,7 @@ function analyzeHap(bytes, packageName) {
17387
17609
  size: inventory.reduce((sum, file) => sum + file.size, 0),
17388
17610
  compressedSize: inventory.reduce((sum, file) => sum + file.compressedSize, 0)
17389
17611
  };
17390
- const largest = [...inventory].sort((a, b) => b.size - a.size || byString4(a.path, b.path)).slice(0, LARGEST_COUNT).map((file) => ({ path: file.path, size: file.size }));
17612
+ const largest = [...inventory].sort((a, b) => b.size - a.size || byString5(a.path, b.path)).slice(0, LARGEST_COUNT).map((file) => ({ path: file.path, size: file.size }));
17391
17613
  const analysis = {
17392
17614
  schemaVersion: 1,
17393
17615
  package: { name: packageName, ...packageBlock },
@@ -17437,18 +17659,18 @@ var SECTION_TITLES = {
17437
17659
  ui: "UI",
17438
17660
  vsync: "VSync"
17439
17661
  };
17440
- function byString5(a, b) {
17662
+ function byString6(a, b) {
17441
17663
  return a < b ? -1 : a > b ? 1 : 0;
17442
17664
  }
17443
17665
  function byEvidenceOrder13(a, b) {
17444
- return byString5(a.kind, b.kind) || a.window.startNs - b.window.startNs || byString5(a.id, b.id);
17666
+ return byString6(a.kind, b.kind) || a.window.startNs - b.window.startNs || byString6(a.id, b.id);
17445
17667
  }
17446
17668
  function emptySeverityCounts() {
17447
17669
  return { info: 0, warn: 0, critical: 0 };
17448
17670
  }
17449
17671
  function buildReport(input) {
17450
- const sections = [...input.sections].sort((a, b) => byString5(a.analyzerId, b.analyzerId)).map((section) => {
17451
- const metrics = [...section.result.metrics].sort((a, b) => byString5(a.id, b.id));
17672
+ const sections = [...input.sections].sort((a, b) => byString6(a.analyzerId, b.analyzerId)).map((section) => {
17673
+ const metrics = [...section.result.metrics].sort((a, b) => byString6(a.id, b.id));
17452
17674
  const evidence2 = [...section.result.evidence].sort(byEvidenceOrder13);
17453
17675
  const reason = evidence2.find((item) => item.kind === "degraded_capability")?.explain;
17454
17676
  return {
@@ -17620,7 +17842,7 @@ function metricNote(metric2) {
17620
17842
  }
17621
17843
  return "";
17622
17844
  }
17623
- var STYLE2 = `
17845
+ var STYLE3 = `
17624
17846
  :root { color-scheme: light; }
17625
17847
  * { box-sizing: border-box; }
17626
17848
  body { margin: 0; padding: 2rem 1.25rem 4rem; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: #1c1f24; background: #f6f7f9; }
@@ -17774,7 +17996,7 @@ function renderReportHtml(model) {
17774
17996
  '<meta charset="utf-8">',
17775
17997
  '<meta name="viewport" content="width=device-width, initial-scale=1">',
17776
17998
  `<title>ohos-perf report \u2014 ${escapeHtml(scenario.app.packageName)}</title>`,
17777
- `<style>${STYLE2}</style>`,
17999
+ `<style>${STYLE3}</style>`,
17778
18000
  "</head>",
17779
18001
  "<body>",
17780
18002
  "<main>",
@@ -18181,7 +18403,7 @@ function totalWeight(stacks) {
18181
18403
  }
18182
18404
  return total;
18183
18405
  }
18184
- var STYLE3 = `
18406
+ var STYLE4 = `
18185
18407
  :root { color-scheme: light; }
18186
18408
  * { box-sizing: border-box; }
18187
18409
  body { margin: 0; padding: 2rem 1.25rem 4rem; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: #1c1f24; background: #f6f7f9; }
@@ -18204,7 +18426,7 @@ function renderFlamegraphHtml(input) {
18204
18426
  '<meta charset="utf-8">',
18205
18427
  '<meta name="viewport" content="width=device-width, initial-scale=1">',
18206
18428
  `<title>Flame graph \u2014 ${escapeHtml(input.app)}</title>`,
18207
- `<style>${STYLE3}</style>`,
18429
+ `<style>${STYLE4}</style>`,
18208
18430
  "</head>",
18209
18431
  "<body>",
18210
18432
  "<main>",
@@ -18326,6 +18548,7 @@ export {
18326
18548
  buildMatrix,
18327
18549
  buildNativeTimeline,
18328
18550
  buildReport,
18551
+ buildTrend,
18329
18552
  categorize,
18330
18553
  classifyNativePath,
18331
18554
  compareImages,
@@ -18405,6 +18628,8 @@ export {
18405
18628
  renderReportXlsx,
18406
18629
  renderScenesComparison,
18407
18630
  renderSummaryJson,
18631
+ renderTrendHtml,
18632
+ renderTrendJson,
18408
18633
  renderUiDiffHtml,
18409
18634
  resolveAppIdentity,
18410
18635
  resolveAppIpids,
@@ -18419,6 +18644,7 @@ export {
18419
18644
  sortSteps,
18420
18645
  summarizeReport,
18421
18646
  tableRowCounts,
18647
+ trendRunFromReport,
18422
18648
  unknownQueryError,
18423
18649
  validateRules,
18424
18650
  writeProcfsSamples,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-perf/core",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty analyzers with provenance and fidelity, reports and a scenario runner",
5
5
  "keywords": [
6
6
  "harmonyos",