@ohos-perf/core 0.18.0 → 0.19.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 +103 -2
- package/dist/index.js +174 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -399,6 +399,12 @@ interface SceneLayout {
|
|
|
399
399
|
* carries one. Nothing here produces it yet; it is read when present.
|
|
400
400
|
*/
|
|
401
401
|
redundantFile: string;
|
|
402
|
+
/**
|
|
403
|
+
* `coverageReport.json`: coverage written by an instrumented build and the
|
|
404
|
+
* external `bjc` toolchain. Nothing here produces it; it is read when present
|
|
405
|
+
* and its absence is a named `no_data` rather than a zero.
|
|
406
|
+
*/
|
|
407
|
+
coverageFile: string;
|
|
402
408
|
/**
|
|
403
409
|
* `jsheap.heapsnapshot`: the raw heap snapshot a `--mem-jsheap` capture
|
|
404
410
|
* pulled. Opaque to this package; it exists for DevEco Studio to open.
|
|
@@ -3607,7 +3613,7 @@ declare class ThreadStateQuery {
|
|
|
3607
3613
|
forItids(itids: number[], range?: TimeRange): ThreadState[];
|
|
3608
3614
|
}
|
|
3609
3615
|
|
|
3610
|
-
type EvidenceKind = 'no_data' | 'jank' | 'frame_load' | 'empty_frame' | 'vsync_anomaly' | 'fps_baseline' | 'degraded_capability' | 'fault_pattern' | 'binder_hotspot' | 'thread_redundancy' | 'memory_growth' | 'native_memory' | 'hilog_match' | 'gc_pressure' | 'rs_skip' | 'startup' | 'ui_tree' | 'tech_stack' | 'duplicate_asset' | 'oversized_asset' | 'symbol_stats' | 'unresolved_symbol' | 'redundant_file';
|
|
3616
|
+
type EvidenceKind = 'no_data' | 'jank' | 'frame_load' | 'empty_frame' | 'vsync_anomaly' | 'fps_baseline' | 'degraded_capability' | 'fault_pattern' | 'binder_hotspot' | 'thread_redundancy' | 'memory_growth' | 'native_memory' | 'hilog_match' | 'gc_pressure' | 'rs_skip' | 'startup' | 'ui_tree' | 'tech_stack' | 'duplicate_asset' | 'oversized_asset' | 'symbol_stats' | 'unresolved_symbol' | 'redundant_file' | 'coverage';
|
|
3611
3617
|
/**
|
|
3612
3618
|
* A follow-up query an agent can issue to drill into an evidence item.
|
|
3613
3619
|
*
|
|
@@ -3790,6 +3796,15 @@ interface AnalyzeContext {
|
|
|
3790
3796
|
* `no_data` with a reason when it is absent rather than three zeros.
|
|
3791
3797
|
*/
|
|
3792
3798
|
redundantFile?: string;
|
|
3799
|
+
/**
|
|
3800
|
+
* The raw `coverageReport.json` a scene carried, when it did.
|
|
3801
|
+
*
|
|
3802
|
+
* Written by an external instrumented build and the `bjc` toolchain, never by
|
|
3803
|
+
* this package. The analyzer reports `no_data` with a reason when it is
|
|
3804
|
+
* absent rather than a zero — HapRay silently skips the section, which makes
|
|
3805
|
+
* "not measured" and "0% covered" the same absence.
|
|
3806
|
+
*/
|
|
3807
|
+
coverage?: string;
|
|
3793
3808
|
/**
|
|
3794
3809
|
* The scene's flattened UI tree, when it carried a `ui.json`. The `ui`
|
|
3795
3810
|
* analyzer decides from what it is given rather than declaring `ui.tree` as a
|
|
@@ -4406,6 +4421,92 @@ interface BundleRerenderInput {
|
|
|
4406
4421
|
*/
|
|
4407
4422
|
declare function renderBundle(input: BundleRerenderInput): Array<[string, string | Uint8Array]>;
|
|
4408
4423
|
|
|
4424
|
+
/**
|
|
4425
|
+
* Coverage ingestion (HapRay parity row 24).
|
|
4426
|
+
*
|
|
4427
|
+
* HapRay does not measure coverage. It shells out to `bjc`, which needs an
|
|
4428
|
+
* instrumented build (`ohos-test-coverage=true`, `coverage-mode=black`), a
|
|
4429
|
+
* debug HAP, an on-device cache, `aa dump` and a matching project source path
|
|
4430
|
+
* — and when any of that is missing its analyzer returns `None`, so the
|
|
4431
|
+
* section disappears from the report. A reader cannot then tell "coverage was
|
|
4432
|
+
* never measured" from "0% of lines ran", which are opposite conclusions.
|
|
4433
|
+
*
|
|
4434
|
+
* This package does not ship `bjc` and will not pretend to: an instrumented
|
|
4435
|
+
* build is a property of how the app was compiled, not something an analysis
|
|
4436
|
+
* tool can supply after the fact. What it does instead is read the report
|
|
4437
|
+
* `bjc` writes — the very document HapRay's own HTML template renders — and
|
|
4438
|
+
* report it as *supplied* data, with the producing tool named in provenance.
|
|
4439
|
+
* A scene without one degrades with a reason, so the absence is visible.
|
|
4440
|
+
*
|
|
4441
|
+
* ## The document
|
|
4442
|
+
*
|
|
4443
|
+
* The shape is fixed by bjc's report template:
|
|
4444
|
+
*
|
|
4445
|
+
* {
|
|
4446
|
+
* "date": "2026-11-17T10:00:00.000Z",
|
|
4447
|
+
* "summary": { "lines": { "total": 400, "covered": 300, "pct": 75 },
|
|
4448
|
+
* "functions": { "total": 40, "covered": 30, "pct": 75 },
|
|
4449
|
+
* "branches": { "total": 80, "covered": 40, "pct": 50 } },
|
|
4450
|
+
* "files": [ { "path": "entry/src/main/ets/pages/Index.ets",
|
|
4451
|
+
* "summary": { … same three … } } ]
|
|
4452
|
+
* }
|
|
4453
|
+
*
|
|
4454
|
+
* The `pct` fields are recomputed rather than trusted: keeping the producer's
|
|
4455
|
+
* rounding would make this report a function of a tool this package does not
|
|
4456
|
+
* control, and a `total` of zero has to be 0% rather than `NaN`.
|
|
4457
|
+
*/
|
|
4458
|
+
|
|
4459
|
+
/** One of the three things bjc counts: `covered / total`. */
|
|
4460
|
+
interface CoverageCounts {
|
|
4461
|
+
readonly covered: number;
|
|
4462
|
+
readonly total: number;
|
|
4463
|
+
}
|
|
4464
|
+
/** The same counts, plus the percentage this module computes from them. */
|
|
4465
|
+
interface CoverageRatio extends CoverageCounts {
|
|
4466
|
+
/** `covered / total * 100`, rounded to two decimals; 0 when `total` is 0. */
|
|
4467
|
+
readonly percent: number;
|
|
4468
|
+
}
|
|
4469
|
+
/** One file's three ratios. */
|
|
4470
|
+
interface CoverageFile {
|
|
4471
|
+
readonly path: string;
|
|
4472
|
+
readonly lines: CoverageRatio;
|
|
4473
|
+
readonly functions: CoverageRatio;
|
|
4474
|
+
readonly branches: CoverageRatio;
|
|
4475
|
+
}
|
|
4476
|
+
/** A parsed `coverageReport.json`. */
|
|
4477
|
+
interface CoverageReport {
|
|
4478
|
+
/** The producer's timestamp, verbatim; empty when the document had none. */
|
|
4479
|
+
readonly date: string;
|
|
4480
|
+
readonly summary: {
|
|
4481
|
+
readonly lines: CoverageRatio;
|
|
4482
|
+
readonly functions: CoverageRatio;
|
|
4483
|
+
readonly branches: CoverageRatio;
|
|
4484
|
+
};
|
|
4485
|
+
/** Per-file ratios, sorted by path so the document is byte-stable. */
|
|
4486
|
+
readonly files: readonly CoverageFile[];
|
|
4487
|
+
}
|
|
4488
|
+
/**
|
|
4489
|
+
* Parse a `coverageReport.json`.
|
|
4490
|
+
*
|
|
4491
|
+
* Malformed JSON is a refusal that says so, not a `SyntaxError` from
|
|
4492
|
+
* `JSON.parse` surfacing through the CLI as an internal error.
|
|
4493
|
+
*/
|
|
4494
|
+
declare function parseCoverageReport(text: string): CoverageReport;
|
|
4495
|
+
/**
|
|
4496
|
+
* The analyzer.
|
|
4497
|
+
*
|
|
4498
|
+
* No capability is required: the report is a scene file, and the scene either
|
|
4499
|
+
* carried one or did not. The fidelity is `approximate` — the numbers are exact
|
|
4500
|
+
* about the instrumented build and say nothing about the app as shipped, so a
|
|
4501
|
+
* consumer that read them as a property of the release would be making a claim
|
|
4502
|
+
* this package cannot support. The collector names the file they came from.
|
|
4503
|
+
*/
|
|
4504
|
+
declare class CoverageAnalyzer implements Analyzer {
|
|
4505
|
+
readonly id = "coverage";
|
|
4506
|
+
readonly requires: never[];
|
|
4507
|
+
run(ctx: AnalyzeContext): Promise<AnalyzeResult>;
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4409
4510
|
/**
|
|
4410
4511
|
* Executing one scenario action against a device.
|
|
4411
4512
|
*
|
|
@@ -6331,4 +6432,4 @@ interface FlamegraphPageInput {
|
|
|
6331
6432
|
*/
|
|
6332
6433
|
declare function renderFlamegraphHtml(input: FlamegraphPageInput): string;
|
|
6333
6434
|
|
|
6334
|
-
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, BUNDLE_RENDERED_FILES, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, type BundleRerenderInput, 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, type ExplorationAction, type ExplorationClock, type ExplorationDevice, type ExplorationDeviceOptions, type ExplorationHost, type ExplorationOptions, type ExplorationOutcome, type ExplorationResult, type ExplorationState, type ExplorationStep, type ExplorationStrategy, type ExplorationTargetDevice, 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, deviceExplorationHost, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, explorationDevice, explore, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hashTree, 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, planNextAction, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderBundle, 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 };
|
|
6435
|
+
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, BUNDLE_RENDERED_FILES, type BaselineComparison, type BelowThresholdPattern, type BinderAnalysis, BinderAnalyzer, type BinderEndpoint, type BinderEvent, type BinderInterfaceStat, type BinderProcessStat, BinderQuery, type BinderThreadStat, type BinderTransaction, type BundleRerenderInput, 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, CoverageAnalyzer, type CoverageCounts, type CoverageFile, type CoverageRatio, type CoverageReport, 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, type ExplorationAction, type ExplorationClock, type ExplorationDevice, type ExplorationDeviceOptions, type ExplorationHost, type ExplorationOptions, type ExplorationOutcome, type ExplorationResult, type ExplorationState, type ExplorationStep, type ExplorationStrategy, type ExplorationTargetDevice, 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, deviceExplorationHost, dhash, diffTrees, discoverCases, encodePng, escapeHtml, evidence, executeAction, explorationDevice, explore, filterEmptyFrames, flattenUiTree, ftracePlugin, gpuPlugin, hapSection, hashTree, hiperfRecordCommand, ingestScene, isUnresolvedSymbol, isZip, loadCases, lookupQuery, markRegions, matchHapRules, matchRules, matchSelector, memoryPlugin, metric, nativeEventKind, nativehookPlugin, nodeIdentity, openDb, openZip, pairNativeMemory, paritySummary, parseBounds, parseCoverageReport, parseFpsCounts, parseHilogLine, parseHilogText, parseHiperfSummary, parseHitches, parseProcfsStatus, parseRedundantFile, parseScenario, parseSelector, parseSmapsRollup, planNextAction, queryDefinitions, readHidumperCapture, readHilogText, readJsheapSnapshot, readProcfsSamples, readSceneMetadata, readUiTree, renderBundle, 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
|
@@ -2845,6 +2845,7 @@ function createSceneLayout(root) {
|
|
|
2845
2845
|
hilogFile: join3(root, "hilog.log"),
|
|
2846
2846
|
hilogJsonlFile: join3(root, "hilog.jsonl"),
|
|
2847
2847
|
redundantFile: join3(root, "redundant_file.txt"),
|
|
2848
|
+
coverageFile: join3(root, "coverageReport.json"),
|
|
2848
2849
|
jsheapFile: join3(root, "jsheap.heapsnapshot"),
|
|
2849
2850
|
metadataFile: join3(root, "scene.json")
|
|
2850
2851
|
};
|
|
@@ -6302,8 +6303,8 @@ var PARITY_ROWS = [
|
|
|
6302
6303
|
{
|
|
6303
6304
|
row: 24,
|
|
6304
6305
|
name: "Coverage",
|
|
6305
|
-
status: "
|
|
6306
|
-
reason: "
|
|
6306
|
+
status: "ported",
|
|
6307
|
+
reason: ""
|
|
6307
6308
|
},
|
|
6308
6309
|
{
|
|
6309
6310
|
row: 25,
|
|
@@ -7650,6 +7651,173 @@ function renderBundle(input) {
|
|
|
7650
7651
|
];
|
|
7651
7652
|
}
|
|
7652
7653
|
|
|
7654
|
+
// src/analyze/coverage.ts
|
|
7655
|
+
function isRecord7(value) {
|
|
7656
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7657
|
+
}
|
|
7658
|
+
function percentOf(counts) {
|
|
7659
|
+
if (counts.total === 0) return 0;
|
|
7660
|
+
return Math.round(counts.covered / counts.total * 1e4) / 100;
|
|
7661
|
+
}
|
|
7662
|
+
function readCounts(value, section) {
|
|
7663
|
+
if (!isRecord7(value)) {
|
|
7664
|
+
throw new OhosPerfError(
|
|
7665
|
+
`coverageReport.json: ${section} is missing or not an object`,
|
|
7666
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7667
|
+
);
|
|
7668
|
+
}
|
|
7669
|
+
const total = value["total"];
|
|
7670
|
+
const covered = value["covered"];
|
|
7671
|
+
for (const [name, count] of [["total", total], ["covered", covered]]) {
|
|
7672
|
+
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) {
|
|
7673
|
+
throw new OhosPerfError(
|
|
7674
|
+
`coverageReport.json: ${section}.${name} must be a non-negative integer (got ${JSON.stringify(count)})`,
|
|
7675
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7676
|
+
);
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
if (covered > total) {
|
|
7680
|
+
throw new OhosPerfError(
|
|
7681
|
+
`coverageReport.json: ${section}.covered (${String(covered)}) exceeds ${section}.total (${String(total)}); a report cannot cover more than exists`,
|
|
7682
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7683
|
+
);
|
|
7684
|
+
}
|
|
7685
|
+
return { covered, total };
|
|
7686
|
+
}
|
|
7687
|
+
function readSummary(value, section) {
|
|
7688
|
+
if (!isRecord7(value)) {
|
|
7689
|
+
throw new OhosPerfError(
|
|
7690
|
+
`coverageReport.json: ${section} is missing or not an object`,
|
|
7691
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7692
|
+
);
|
|
7693
|
+
}
|
|
7694
|
+
const ratio = (name) => {
|
|
7695
|
+
const counts = readCounts(value[name], `${section}.${name}`);
|
|
7696
|
+
return { ...counts, percent: percentOf(counts) };
|
|
7697
|
+
};
|
|
7698
|
+
return { lines: ratio("lines"), functions: ratio("functions"), branches: ratio("branches") };
|
|
7699
|
+
}
|
|
7700
|
+
function parseCoverageReport(text) {
|
|
7701
|
+
let document;
|
|
7702
|
+
try {
|
|
7703
|
+
document = JSON.parse(text);
|
|
7704
|
+
} catch (err) {
|
|
7705
|
+
throw new OhosPerfError(
|
|
7706
|
+
`coverageReport.json is not valid JSON: ${err.message}`,
|
|
7707
|
+
{ code: "SCENARIO_BAD_INPUT", cause: err }
|
|
7708
|
+
);
|
|
7709
|
+
}
|
|
7710
|
+
if (!isRecord7(document) || !("summary" in document) || !("files" in document)) {
|
|
7711
|
+
throw new OhosPerfError(
|
|
7712
|
+
'coverageReport.json is not a coverage report: it has no "summary" and "files"',
|
|
7713
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7714
|
+
);
|
|
7715
|
+
}
|
|
7716
|
+
const summary = readSummary(document["summary"], "summary");
|
|
7717
|
+
const filesRaw = document["files"];
|
|
7718
|
+
if (!Array.isArray(filesRaw)) {
|
|
7719
|
+
throw new OhosPerfError('coverageReport.json: "files" is not an array', {
|
|
7720
|
+
code: "SCENARIO_BAD_INPUT"
|
|
7721
|
+
});
|
|
7722
|
+
}
|
|
7723
|
+
const files = filesRaw.map((entry, index) => {
|
|
7724
|
+
if (!isRecord7(entry) || typeof entry["path"] !== "string") {
|
|
7725
|
+
throw new OhosPerfError(
|
|
7726
|
+
`coverageReport.json: files[${index}] has no string "path"`,
|
|
7727
|
+
{ code: "SCENARIO_BAD_INPUT" }
|
|
7728
|
+
);
|
|
7729
|
+
}
|
|
7730
|
+
const fileSummary = readSummary(entry["summary"], `files[${index}].summary`);
|
|
7731
|
+
return {
|
|
7732
|
+
path: entry["path"],
|
|
7733
|
+
lines: fileSummary.lines,
|
|
7734
|
+
functions: fileSummary.functions,
|
|
7735
|
+
branches: fileSummary.branches
|
|
7736
|
+
};
|
|
7737
|
+
});
|
|
7738
|
+
files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
7739
|
+
return {
|
|
7740
|
+
date: typeof document["date"] === "string" ? document["date"] : "",
|
|
7741
|
+
summary,
|
|
7742
|
+
files
|
|
7743
|
+
};
|
|
7744
|
+
}
|
|
7745
|
+
var CoverageAnalyzer = class {
|
|
7746
|
+
id = "coverage";
|
|
7747
|
+
requires = [];
|
|
7748
|
+
async run(ctx) {
|
|
7749
|
+
const text = ctx.coverage;
|
|
7750
|
+
if (text === void 0) {
|
|
7751
|
+
return {
|
|
7752
|
+
metrics: [],
|
|
7753
|
+
evidence: [
|
|
7754
|
+
evidence({
|
|
7755
|
+
kind: "no_data",
|
|
7756
|
+
severity: "info",
|
|
7757
|
+
subject: { process: ctx.app.packageName },
|
|
7758
|
+
window: ctx.window,
|
|
7759
|
+
signals: {},
|
|
7760
|
+
explain: "the scene carries no coverageReport.json; coverage was not measured. An instrumented build (ohos-test-coverage=true) plus the bjc toolchain produces one, and this analyzer reads it rather than running bjc",
|
|
7761
|
+
drillDown: [],
|
|
7762
|
+
key: "coverage:no-report"
|
|
7763
|
+
})
|
|
7764
|
+
]
|
|
7765
|
+
};
|
|
7766
|
+
}
|
|
7767
|
+
const report = parseCoverageReport(text);
|
|
7768
|
+
const make = (id, value, unit) => metric({
|
|
7769
|
+
id,
|
|
7770
|
+
value,
|
|
7771
|
+
unit,
|
|
7772
|
+
fidelity: "approximate",
|
|
7773
|
+
provenance: {
|
|
7774
|
+
collector: "scene:coverageReport.json",
|
|
7775
|
+
table: "coverage",
|
|
7776
|
+
rows: report.files.length,
|
|
7777
|
+
device: ctx.deviceId
|
|
7778
|
+
}
|
|
7779
|
+
});
|
|
7780
|
+
const metrics = [
|
|
7781
|
+
make("coverage.lines.percent", report.summary.lines.percent, "%"),
|
|
7782
|
+
make("coverage.lines.covered", report.summary.lines.covered, "count"),
|
|
7783
|
+
make("coverage.lines.total", report.summary.lines.total, "count"),
|
|
7784
|
+
make("coverage.functions.percent", report.summary.functions.percent, "%"),
|
|
7785
|
+
make("coverage.branches.percent", report.summary.branches.percent, "%"),
|
|
7786
|
+
make("coverage.files.count", report.files.length, "count")
|
|
7787
|
+
];
|
|
7788
|
+
const worst = report.files.reduce((low, file) => {
|
|
7789
|
+
if (low === void 0) return file;
|
|
7790
|
+
if (file.lines.percent !== low.lines.percent) {
|
|
7791
|
+
return file.lines.percent < low.lines.percent ? file : low;
|
|
7792
|
+
}
|
|
7793
|
+
return file.path < low.path ? file : low;
|
|
7794
|
+
}, void 0);
|
|
7795
|
+
const items = [];
|
|
7796
|
+
if (worst !== void 0) {
|
|
7797
|
+
items.push(
|
|
7798
|
+
evidence({
|
|
7799
|
+
kind: "coverage",
|
|
7800
|
+
severity: worst.lines.percent < 50 ? "warn" : "info",
|
|
7801
|
+
subject: { process: ctx.app.packageName },
|
|
7802
|
+
window: ctx.window,
|
|
7803
|
+
signals: {
|
|
7804
|
+
path: worst.path,
|
|
7805
|
+
linesPercent: worst.lines.percent,
|
|
7806
|
+
linesCovered: worst.lines.covered,
|
|
7807
|
+
linesTotal: worst.lines.total,
|
|
7808
|
+
functionsPercent: worst.functions.percent,
|
|
7809
|
+
branchesPercent: worst.branches.percent
|
|
7810
|
+
},
|
|
7811
|
+
explain: `${worst.path} is the least-covered file at ${worst.lines.percent}% of lines (${worst.lines.covered}/${worst.lines.total})`,
|
|
7812
|
+
drillDown: [],
|
|
7813
|
+
key: worst.path
|
|
7814
|
+
})
|
|
7815
|
+
);
|
|
7816
|
+
}
|
|
7817
|
+
return { metrics, evidence: items };
|
|
7818
|
+
}
|
|
7819
|
+
};
|
|
7820
|
+
|
|
7653
7821
|
// src/scenario/actions.ts
|
|
7654
7822
|
var MAX_SCROLLS = 5;
|
|
7655
7823
|
var DEFAULT_DISTANCE = 40;
|
|
@@ -17462,7 +17630,8 @@ function defaultAnalyzers() {
|
|
|
17462
17630
|
new ComponentReuseAnalyzer(),
|
|
17463
17631
|
new HilogAnalyzer(),
|
|
17464
17632
|
new UiAnalyzer(),
|
|
17465
|
-
new RedundantFileAnalyzer()
|
|
17633
|
+
new RedundantFileAnalyzer(),
|
|
17634
|
+
new CoverageAnalyzer()
|
|
17466
17635
|
];
|
|
17467
17636
|
}
|
|
17468
17637
|
|
|
@@ -18694,6 +18863,7 @@ export {
|
|
|
18694
18863
|
CallstackQuery,
|
|
18695
18864
|
CapabilityMatrix,
|
|
18696
18865
|
ComponentReuseAnalyzer,
|
|
18866
|
+
CoverageAnalyzer,
|
|
18697
18867
|
DEFAULT_HILOG_RULES,
|
|
18698
18868
|
DEFAULT_QUERY_LIMIT,
|
|
18699
18869
|
DEVICE_PERF_PATH,
|
|
@@ -18842,6 +19012,7 @@ export {
|
|
|
18842
19012
|
pairNativeMemory,
|
|
18843
19013
|
paritySummary,
|
|
18844
19014
|
parseBounds,
|
|
19015
|
+
parseCoverageReport,
|
|
18845
19016
|
parseFpsCounts,
|
|
18846
19017
|
parseHilogLine,
|
|
18847
19018
|
parseHilogText,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-perf/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty analyzers with provenance and fidelity, reports and a scenario runner",
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty-one analyzers with provenance and fidelity, reports and a scenario runner",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"harmonyos",
|
|
7
7
|
"openharmony",
|