@ohos-perf/core 0.13.3 → 0.15.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 +118 -2
- package/dist/index.js +322 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2127,6 +2127,106 @@ declare function nodeIdentity(node: UiNode): string;
|
|
|
2127
2127
|
*/
|
|
2128
2128
|
declare function diffTrees(before: readonly UiNode[], after: readonly UiNode[]): UiTreeDiff;
|
|
2129
2129
|
|
|
2130
|
+
/**
|
|
2131
|
+
* Animation labelling for a start/end capture pair (HapRay parity row 31).
|
|
2132
|
+
*
|
|
2133
|
+
* Ported from `ui_detector/image_comparator.py` and the label bands in
|
|
2134
|
+
* `analyze/ui_analyzer.py`: crop a region from both screenshots, compare their
|
|
2135
|
+
* dHashes, and call the region an animation when the similarity falls under
|
|
2136
|
+
* 85%. The bands are HapRay's — `major_change` under 50, `moderate_change`
|
|
2137
|
+
* under 70, `minor_change` under 85 — and are kept so a reader who knows
|
|
2138
|
+
* HapRay's numbers reads the same ones here.
|
|
2139
|
+
*
|
|
2140
|
+
* ## Why this is narrower than HapRay
|
|
2141
|
+
*
|
|
2142
|
+
* HapRay's label rests on pixels alone, and pixels alone are not evidence of
|
|
2143
|
+
* an animation. A blinking text cursor, a system clock in the status bar and a
|
|
2144
|
+
* video frame all move under a region the app never re-rendered; conversely a
|
|
2145
|
+
* node the tree added but the screen never painted is a rendering defect, not
|
|
2146
|
+
* an animation. So a region is labelled only when *both* the pixels and the
|
|
2147
|
+
* tree moved inside it, and each half is reported so the caller can see the
|
|
2148
|
+
* agreement rather than take the label on trust. A pixel-only movement is
|
|
2149
|
+
* returned separately — it is a real observation, just not this label.
|
|
2150
|
+
*
|
|
2151
|
+
* ## Resolution dependence
|
|
2152
|
+
*
|
|
2153
|
+
* The dHash is computed at a fixed 9×8 grid, so a region smaller than that
|
|
2154
|
+
* grid cannot express its own detail: two 3×3 regions hash identically
|
|
2155
|
+
* whatever they contain. Regions below {@link MIN_HASH_PIXELS} are therefore
|
|
2156
|
+
* not labelled, and say so in `unmeasured`.
|
|
2157
|
+
*/
|
|
2158
|
+
/** HapRay's similarity bands, as percentages. */
|
|
2159
|
+
declare const ANIMATION_BANDS: {
|
|
2160
|
+
readonly major: 50;
|
|
2161
|
+
readonly moderate: 70;
|
|
2162
|
+
readonly minor: 85;
|
|
2163
|
+
};
|
|
2164
|
+
/** A region smaller than this cannot fill the 9×8 hash grid. */
|
|
2165
|
+
declare const MIN_HASH_PIXELS: number;
|
|
2166
|
+
type AnimationSeverity = 'major_change' | 'moderate_change' | 'minor_change';
|
|
2167
|
+
/** How much the pixels inside one region moved between the two captures. */
|
|
2168
|
+
interface RegionPixelChange {
|
|
2169
|
+
readonly bounds: Rect;
|
|
2170
|
+
/** 0..1; 1 means the two hashes are identical. */
|
|
2171
|
+
readonly similarity: number;
|
|
2172
|
+
/** Fraction of the region's pixels whose channels differ by more than the tolerance. */
|
|
2173
|
+
readonly changedRatio: number;
|
|
2174
|
+
readonly dhashA: string;
|
|
2175
|
+
readonly dhashB: string;
|
|
2176
|
+
}
|
|
2177
|
+
/** A region both halves agree moved: an animation label. */
|
|
2178
|
+
interface AnimationLabel extends RegionPixelChange {
|
|
2179
|
+
readonly label: 'animation';
|
|
2180
|
+
readonly severity: AnimationSeverity;
|
|
2181
|
+
/** Tree differences whose bounds fall inside this region. */
|
|
2182
|
+
readonly treeChanges: number;
|
|
2183
|
+
}
|
|
2184
|
+
/** A region the pixels moved in while the tree did not. */
|
|
2185
|
+
interface PixelOnlyChange extends RegionPixelChange {
|
|
2186
|
+
readonly note: 'pixels changed, tree did not: not labelled an animation';
|
|
2187
|
+
}
|
|
2188
|
+
/** A region that was skipped, and why. */
|
|
2189
|
+
interface UnmeasuredRegion {
|
|
2190
|
+
readonly bounds: Rect;
|
|
2191
|
+
readonly reason: string;
|
|
2192
|
+
}
|
|
2193
|
+
interface AnimationAnalysis {
|
|
2194
|
+
readonly animations: AnimationLabel[];
|
|
2195
|
+
readonly pixelOnly: PixelOnlyChange[];
|
|
2196
|
+
readonly unmeasured: UnmeasuredRegion[];
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* HapRay's severity band for a similarity percentage.
|
|
2200
|
+
*
|
|
2201
|
+
* Returns `undefined` at or above the 85% band: HapRay calls that
|
|
2202
|
+
* `no_change`, and a label for no change is not an animation.
|
|
2203
|
+
*/
|
|
2204
|
+
declare function animationSeverity(similarityPercent: number): AnimationSeverity | undefined;
|
|
2205
|
+
/**
|
|
2206
|
+
* Crop a region out of an image.
|
|
2207
|
+
*
|
|
2208
|
+
* `right` and `bottom` are exclusive, matching `bounds` as `uitest` writes it
|
|
2209
|
+
* (`[0,0][8,4]` on an 8×4 screen). A region is clipped to the image rather
|
|
2210
|
+
* than refused: a node whose bounds run past the screen still has a visible
|
|
2211
|
+
* part, and that part is what the capture can speak about.
|
|
2212
|
+
*/
|
|
2213
|
+
declare function cropRegion(image: RgbaImage, rect: Rect): RgbaImage;
|
|
2214
|
+
/** Compare one region across the two captures, or `undefined` when too small. */
|
|
2215
|
+
declare function compareRegion(a: RgbaImage, b: RgbaImage, rect: Rect, tolerance: number): RegionPixelChange | undefined;
|
|
2216
|
+
/**
|
|
2217
|
+
* Label the regions both halves agree moved.
|
|
2218
|
+
*
|
|
2219
|
+
* `treeRegions` are the bounds the tree diff reported, each with its count of
|
|
2220
|
+
* differences; `pixelOnlyBounds` is where to look when the tree reported
|
|
2221
|
+
* nothing at all — the whole screen, because there is no node to narrow it to.
|
|
2222
|
+
* A region whose pixels moved and whose tree did not is returned in
|
|
2223
|
+
* `pixelOnly`, never promoted.
|
|
2224
|
+
*/
|
|
2225
|
+
declare function analyseAnimations(a: RgbaImage, b: RgbaImage, treeRegions: ReadonlyArray<{
|
|
2226
|
+
bounds: Rect;
|
|
2227
|
+
changes: number;
|
|
2228
|
+
}>, pixelOnlyBounds: Rect | undefined, tolerance: number): AnimationAnalysis;
|
|
2229
|
+
|
|
2130
2230
|
/** What one side of the comparison contained, as the page and JSON report it. */
|
|
2131
2231
|
interface UiDiffSide {
|
|
2132
2232
|
readonly dir: string;
|
|
@@ -2155,6 +2255,19 @@ interface UiDiff {
|
|
|
2155
2255
|
readonly image: ImageComparison | null;
|
|
2156
2256
|
readonly tree: UiTreeDiff | null;
|
|
2157
2257
|
readonly regions: Rect[];
|
|
2258
|
+
/**
|
|
2259
|
+
* Regions both the pixels and the tree agree moved between the two captures
|
|
2260
|
+
* (HapRay parity row 31). Empty for a tree-only comparison, which has no
|
|
2261
|
+
* pixels to compare.
|
|
2262
|
+
*/
|
|
2263
|
+
readonly animations: AnimationAnalysis['animations'];
|
|
2264
|
+
/**
|
|
2265
|
+
* Regions whose pixels moved while the tree did not: a cursor blink, a video
|
|
2266
|
+
* frame, a system clock. Reported, never labelled an animation.
|
|
2267
|
+
*/
|
|
2268
|
+
readonly pixelOnly: AnimationAnalysis['pixelOnly'];
|
|
2269
|
+
/** Regions too small for the dHash grid to say anything about. */
|
|
2270
|
+
readonly unmeasuredRegions: AnimationAnalysis['unmeasured'];
|
|
2158
2271
|
readonly degraded: string[];
|
|
2159
2272
|
}
|
|
2160
2273
|
/** Where `compareSceneDirs` writes its artifacts. */
|
|
@@ -5266,6 +5379,8 @@ declare class EmptyFrameAnalyzer implements Analyzer {
|
|
|
5266
5379
|
run(ctx: AnalyzeContext): Promise<AnalyzeResult>;
|
|
5267
5380
|
}
|
|
5268
5381
|
|
|
5382
|
+
/** Which backtracking method produced a trace. */
|
|
5383
|
+
type RsSkipTraceMethod = 'rs_api' | 'nativewindow';
|
|
5269
5384
|
/** One RenderService frame that skipped, and what it traced back to. */
|
|
5270
5385
|
interface RsSkipFrame {
|
|
5271
5386
|
frame: Frame;
|
|
@@ -5273,10 +5388,11 @@ interface RsSkipFrame {
|
|
|
5273
5388
|
events: number;
|
|
5274
5389
|
traced?: {
|
|
5275
5390
|
frame: Frame;
|
|
5276
|
-
/** The buffer event's timestamp. */
|
|
5391
|
+
/** The buffer or `UnMarsh` event's timestamp. */
|
|
5277
5392
|
eventNs: number;
|
|
5278
5393
|
/** `|appFrame.ts - eventNs|`. */
|
|
5279
5394
|
timeDiffNs: number;
|
|
5395
|
+
method: RsSkipTraceMethod;
|
|
5280
5396
|
};
|
|
5281
5397
|
}
|
|
5282
5398
|
interface RsSkipResult {
|
|
@@ -5885,4 +6001,4 @@ interface FlamegraphPageInput {
|
|
|
5885
6001
|
*/
|
|
5886
6002
|
declare function renderFlamegraphHtml(input: FlamegraphPageInput): string;
|
|
5887
6003
|
|
|
5888
|
-
export { type ActionContext, type ActionDevice, type ActionOutcome, type ActiveAlloc, type AnalyzeContext, type AnalyzeResult, type Analyzer, type AnalyzerRun, type AnalyzerSection, 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, 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 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, RenderAnalyzer, type ReportGenerator, type ReportInput, type ReportModel, type ReportScenario, type ReportSection, type ReportSummary, type ReportTotals, type RgbaImage, RsSkipAnalyzer, type RsSkipFrame, type RsSkipResult, 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 UnreleasedRow, type VsyncAnalysis, VsyncAnalyzer, type VsyncPeriod, type VsyncPeriodKind, type VsyncSeverity, type WakeupEvent, type WindowHitches, type ZipArchive, type ZipEntry, aggregateUnreleased, analyzeHap, analyzeThreadWakeup, buildDepGraph, buildHiprofilerConfig, buildInventory, buildMatrix, buildNativeTimeline, buildReport, categorize, classifyNativePath, compareImages, compareResults, compareSceneDirs, compareScenes, compileRules, computeBinderAnalysis, computeComponentReuse, computeFaultTree, computeFpsWindows, computeGc, computeRsSkip, computeThreadAnalysis, computeVsyncAnomalies, connect, createSceneLayout, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5019,6 +5019,108 @@ function diffTrees(before, after) {
|
|
|
5019
5019
|
import { existsSync as existsSync13, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
5020
5020
|
import { join as join7, resolve } from "node:path";
|
|
5021
5021
|
|
|
5022
|
+
// src/ui/animation.ts
|
|
5023
|
+
var ANIMATION_BANDS = {
|
|
5024
|
+
major: 50,
|
|
5025
|
+
moderate: 70,
|
|
5026
|
+
minor: 85
|
|
5027
|
+
};
|
|
5028
|
+
var MIN_HASH_PIXELS = 9 * 8;
|
|
5029
|
+
function animationSeverity(similarityPercent) {
|
|
5030
|
+
if (similarityPercent < ANIMATION_BANDS.major) return "major_change";
|
|
5031
|
+
if (similarityPercent < ANIMATION_BANDS.moderate) return "moderate_change";
|
|
5032
|
+
if (similarityPercent < ANIMATION_BANDS.minor) return "minor_change";
|
|
5033
|
+
return void 0;
|
|
5034
|
+
}
|
|
5035
|
+
function cropRegion(image, rect) {
|
|
5036
|
+
const left = Math.max(0, Math.min(rect.left, rect.right));
|
|
5037
|
+
const right = Math.min(image.width, Math.max(rect.left, rect.right));
|
|
5038
|
+
const top = Math.max(0, Math.min(rect.top, rect.bottom));
|
|
5039
|
+
const bottom = Math.min(image.height, Math.max(rect.top, rect.bottom));
|
|
5040
|
+
const width = Math.max(0, right - left);
|
|
5041
|
+
const height = Math.max(0, bottom - top);
|
|
5042
|
+
const data = new Uint8Array(width * height * 4);
|
|
5043
|
+
for (let y = 0; y < height; y += 1) {
|
|
5044
|
+
const from = ((top + y) * image.width + left) * 4;
|
|
5045
|
+
data.set(image.data.subarray(from, from + width * 4), y * width * 4);
|
|
5046
|
+
}
|
|
5047
|
+
return { width, height, data };
|
|
5048
|
+
}
|
|
5049
|
+
function hammingHex(a, b) {
|
|
5050
|
+
let distance = 0;
|
|
5051
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
5052
|
+
let xor = parseInt(a[i], 16) ^ parseInt(b[i], 16);
|
|
5053
|
+
while (xor !== 0) {
|
|
5054
|
+
distance += xor & 1;
|
|
5055
|
+
xor >>= 1;
|
|
5056
|
+
}
|
|
5057
|
+
}
|
|
5058
|
+
return distance;
|
|
5059
|
+
}
|
|
5060
|
+
function compareRegion(a, b, rect, tolerance) {
|
|
5061
|
+
const left = cropRegion(a, rect);
|
|
5062
|
+
const right = cropRegion(b, rect);
|
|
5063
|
+
const width = Math.min(left.width, right.width);
|
|
5064
|
+
const height = Math.min(left.height, right.height);
|
|
5065
|
+
if (width * height < MIN_HASH_PIXELS) return void 0;
|
|
5066
|
+
const dhashA = dhash(left);
|
|
5067
|
+
const dhashB = dhash(right);
|
|
5068
|
+
let changed = 0;
|
|
5069
|
+
let compared = 0;
|
|
5070
|
+
for (let y = 0; y < height; y += 1) {
|
|
5071
|
+
for (let x = 0; x < width; x += 1) {
|
|
5072
|
+
const at = (y * left.width + x) * 4;
|
|
5073
|
+
const bt = (y * right.width + x) * 4;
|
|
5074
|
+
compared += 1;
|
|
5075
|
+
if (Math.abs(left.data[at] - right.data[bt]) > tolerance || Math.abs(left.data[at + 1] - right.data[bt + 1]) > tolerance || Math.abs(left.data[at + 2] - right.data[bt + 2]) > tolerance || Math.abs(left.data[at + 3] - right.data[bt + 3]) > tolerance) {
|
|
5076
|
+
changed += 1;
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
return {
|
|
5081
|
+
bounds: rect,
|
|
5082
|
+
similarity: 1 - hammingHex(dhashA, dhashB) / 64,
|
|
5083
|
+
changedRatio: compared === 0 ? 0 : changed / compared,
|
|
5084
|
+
dhashA,
|
|
5085
|
+
dhashB
|
|
5086
|
+
};
|
|
5087
|
+
}
|
|
5088
|
+
function analyseAnimations(a, b, treeRegions, pixelOnlyBounds, tolerance) {
|
|
5089
|
+
const animations = [];
|
|
5090
|
+
const pixelOnly = [];
|
|
5091
|
+
const unmeasured = [];
|
|
5092
|
+
const consider = (bounds, treeChanges) => {
|
|
5093
|
+
const pixels = compareRegion(a, b, bounds, tolerance);
|
|
5094
|
+
if (pixels === void 0) {
|
|
5095
|
+
unmeasured.push({
|
|
5096
|
+
bounds,
|
|
5097
|
+
reason: `the region is smaller than the ${MIN_HASH_PIXELS}-pixel dHash grid, so its pixels cannot be compared`
|
|
5098
|
+
});
|
|
5099
|
+
return;
|
|
5100
|
+
}
|
|
5101
|
+
if (pixels.changedRatio === 0) return;
|
|
5102
|
+
if (treeChanges === 0) {
|
|
5103
|
+
pixelOnly.push({
|
|
5104
|
+
...pixels,
|
|
5105
|
+
note: "pixels changed, tree did not: not labelled an animation"
|
|
5106
|
+
});
|
|
5107
|
+
return;
|
|
5108
|
+
}
|
|
5109
|
+
const severity = animationSeverity(pixels.similarity * 100);
|
|
5110
|
+
if (severity === void 0) return;
|
|
5111
|
+
animations.push({ ...pixels, label: "animation", severity, treeChanges });
|
|
5112
|
+
};
|
|
5113
|
+
for (const region of treeRegions) consider(region.bounds, region.changes);
|
|
5114
|
+
if (treeRegions.length === 0 && pixelOnlyBounds !== void 0) {
|
|
5115
|
+
consider(pixelOnlyBounds, 0);
|
|
5116
|
+
}
|
|
5117
|
+
const order = (x, y) => x.bounds.top - y.bounds.top || x.bounds.left - y.bounds.left || x.bounds.bottom - y.bounds.bottom || x.bounds.right - y.bounds.right;
|
|
5118
|
+
animations.sort(order);
|
|
5119
|
+
pixelOnly.sort(order);
|
|
5120
|
+
unmeasured.sort(order);
|
|
5121
|
+
return { animations, pixelOnly, unmeasured };
|
|
5122
|
+
}
|
|
5123
|
+
|
|
5022
5124
|
// src/report/escape.ts
|
|
5023
5125
|
function escapeHtml(value) {
|
|
5024
5126
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
@@ -5119,6 +5221,28 @@ function renderUiDiffHtml(diff) {
|
|
|
5119
5221
|
"</table>"
|
|
5120
5222
|
].join("");
|
|
5121
5223
|
})();
|
|
5224
|
+
const animationSection = (() => {
|
|
5225
|
+
const labels = diff.animations;
|
|
5226
|
+
const pixelOnly = diff.pixelOnly;
|
|
5227
|
+
const unmeasured = diff.unmeasuredRegions;
|
|
5228
|
+
if (labels.length === 0 && pixelOnly.length === 0 && unmeasured.length === 0) {
|
|
5229
|
+
return '<h2>Animations</h2><p class="meta">No region changed in both the pixels and the tree, so no animation is labelled.</p>';
|
|
5230
|
+
}
|
|
5231
|
+
const rect = (bounds) => `[${bounds.left},${bounds.top}][${bounds.right},${bounds.bottom}]`;
|
|
5232
|
+
const rows = [
|
|
5233
|
+
...labels.map((item) => `<tr><td>animation (${escapeHtml(item.severity)})</td><td class="num">${rect(item.bounds)}</td><td class="num">${(item.similarity * 100).toFixed(1)}%</td><td class="num">${item.treeChanges}</td></tr>`),
|
|
5234
|
+
...pixelOnly.map((item) => `<tr><td>pixels only, not labelled</td><td class="num">${rect(item.bounds)}</td><td class="num">${(item.similarity * 100).toFixed(1)}%</td><td class="num">0</td></tr>`),
|
|
5235
|
+
...unmeasured.map((item) => `<tr><td>unmeasured: ${escapeHtml(item.reason)}</td><td class="num">${rect(item.bounds)}</td><td class="num">\u2014</td><td class="num">\u2014</td></tr>`)
|
|
5236
|
+
].join("");
|
|
5237
|
+
return [
|
|
5238
|
+
"<h2>Animations</h2>",
|
|
5239
|
+
`<p class="meta">A region is labelled an animation only when its pixels moved and the tree reports a change inside it. A pixel-only movement \u2014 a cursor, a video frame, a system clock \u2014 is listed but not labelled. Bands follow HapRay: major under ${ANIMATION_BANDS.major}% similar, moderate under ${ANIMATION_BANDS.moderate}%, minor under ${ANIMATION_BANDS.minor}%.</p>`,
|
|
5240
|
+
"<table>",
|
|
5241
|
+
"<thead><tr><th>label</th><th>bounds</th><th>similarity</th><th>tree changes</th></tr></thead>",
|
|
5242
|
+
`<tbody>${rows}</tbody>`,
|
|
5243
|
+
"</table>"
|
|
5244
|
+
].join("");
|
|
5245
|
+
})();
|
|
5122
5246
|
const captureLines = [
|
|
5123
5247
|
diff.a.startedAtMs === void 0 ? void 0 : `a captured at ${diff.a.startedAtMs} ms`,
|
|
5124
5248
|
diff.b.startedAtMs === void 0 ? void 0 : `b captured at ${diff.b.startedAtMs} ms`
|
|
@@ -5143,6 +5267,7 @@ function renderUiDiffHtml(diff) {
|
|
|
5143
5267
|
banner,
|
|
5144
5268
|
screens,
|
|
5145
5269
|
imageNumbers,
|
|
5270
|
+
animationSection,
|
|
5146
5271
|
treeRows,
|
|
5147
5272
|
"<footer>Generated by @ohos-perf/core. No scripts, no network access.</footer>",
|
|
5148
5273
|
"</main>",
|
|
@@ -5193,6 +5318,19 @@ function collectRegions(tree) {
|
|
|
5193
5318
|
);
|
|
5194
5319
|
return regions;
|
|
5195
5320
|
}
|
|
5321
|
+
function regionCounts(tree) {
|
|
5322
|
+
const counts = /* @__PURE__ */ new Map();
|
|
5323
|
+
const all = [...tree.added, ...tree.removed, ...tree.changed];
|
|
5324
|
+
for (const difference2 of all) {
|
|
5325
|
+
if (difference2.bounds === void 0) continue;
|
|
5326
|
+
const rect = difference2.bounds;
|
|
5327
|
+
const key = `${rect.left},${rect.top},${rect.right},${rect.bottom}`;
|
|
5328
|
+
const found = counts.get(key);
|
|
5329
|
+
if (found === void 0) counts.set(key, { bounds: rect, changes: 1 });
|
|
5330
|
+
else found.changes += 1;
|
|
5331
|
+
}
|
|
5332
|
+
return [...counts.values()];
|
|
5333
|
+
}
|
|
5196
5334
|
function readSide(dir, side) {
|
|
5197
5335
|
const layout = createSceneLayout(dir);
|
|
5198
5336
|
const hasImage = existsSync13(layout.screenshotFile);
|
|
@@ -5242,6 +5380,13 @@ async function compareSceneDirs(a, b, opts) {
|
|
|
5242
5380
|
};
|
|
5243
5381
|
};
|
|
5244
5382
|
const regions = collectRegions(tree);
|
|
5383
|
+
const animations = left.image === void 0 || right.image === void 0 || tree === null ? { animations: [], pixelOnly: [], unmeasured: [] } : analyseAnimations(
|
|
5384
|
+
left.image,
|
|
5385
|
+
right.image,
|
|
5386
|
+
regionCounts(tree),
|
|
5387
|
+
{ left: 0, top: 0, right: left.image.width, bottom: left.image.height },
|
|
5388
|
+
opts.tolerance ?? 8
|
|
5389
|
+
);
|
|
5245
5390
|
const diff = {
|
|
5246
5391
|
schemaVersion: 1,
|
|
5247
5392
|
a: side(dirA, left.image, left.nodes),
|
|
@@ -5249,6 +5394,9 @@ async function compareSceneDirs(a, b, opts) {
|
|
|
5249
5394
|
image,
|
|
5250
5395
|
tree,
|
|
5251
5396
|
regions,
|
|
5397
|
+
animations: animations.animations,
|
|
5398
|
+
pixelOnly: animations.pixelOnly,
|
|
5399
|
+
unmeasuredRegions: animations.unmeasured,
|
|
5252
5400
|
degraded
|
|
5253
5401
|
};
|
|
5254
5402
|
const outDir = resolve(opts.outDir);
|
|
@@ -6071,8 +6219,8 @@ var PARITY_ROWS = [
|
|
|
6071
6219
|
{
|
|
6072
6220
|
row: 12,
|
|
6073
6221
|
name: "RenderService skip reverse tracing",
|
|
6074
|
-
status: "
|
|
6075
|
-
reason: "
|
|
6222
|
+
status: "ported",
|
|
6223
|
+
reason: "",
|
|
6076
6224
|
analyzer: "RsSkipAnalyzer"
|
|
6077
6225
|
},
|
|
6078
6226
|
{
|
|
@@ -6192,8 +6340,8 @@ var PARITY_ROWS = [
|
|
|
6192
6340
|
{
|
|
6193
6341
|
row: 31,
|
|
6194
6342
|
name: "UI animation analysis",
|
|
6195
|
-
status: "
|
|
6196
|
-
reason: "
|
|
6343
|
+
status: "ported",
|
|
6344
|
+
reason: "",
|
|
6197
6345
|
analyzer: "UiAnalyzer"
|
|
6198
6346
|
},
|
|
6199
6347
|
{
|
|
@@ -15389,6 +15537,8 @@ var EVENT_LOOKBACK_NS = 5e8;
|
|
|
15389
15537
|
var APP_LOOKAHEAD_NS = 1e7;
|
|
15390
15538
|
var MAX_EVENTS = 5;
|
|
15391
15539
|
var MAX_APP_FRAMES = 10;
|
|
15540
|
+
var WAKEUP_WINDOW_NS = 1e7;
|
|
15541
|
+
var MAX_CHAIN_DEPTH = 5;
|
|
15392
15542
|
function nearest(values, anchor, before, after, limit) {
|
|
15393
15543
|
return values.filter((value) => value >= anchor - before && value <= anchor + after).sort((a, b) => {
|
|
15394
15544
|
const distance = Math.abs(a - anchor) - Math.abs(b - anchor);
|
|
@@ -15404,6 +15554,81 @@ function renderServiceIpids(processes) {
|
|
|
15404
15554
|
}
|
|
15405
15555
|
return ipids;
|
|
15406
15556
|
}
|
|
15557
|
+
function hasTable3(db, name) {
|
|
15558
|
+
return db.query(
|
|
15559
|
+
"SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",
|
|
15560
|
+
[name]
|
|
15561
|
+
).length > 0;
|
|
15562
|
+
}
|
|
15563
|
+
var UNMARSH_PID = /recv data from (\d+)/;
|
|
15564
|
+
function parseUnmarshPid(name) {
|
|
15565
|
+
const match = UNMARSH_PID.exec(name);
|
|
15566
|
+
return match === null ? void 0 : Number(match[1]);
|
|
15567
|
+
}
|
|
15568
|
+
function readApiCaches(db, rsIpids) {
|
|
15569
|
+
if (!hasTable3(db, "instant")) return void 0;
|
|
15570
|
+
const wakeups = /* @__PURE__ */ new Map();
|
|
15571
|
+
const rows = db.query(
|
|
15572
|
+
`SELECT ref, wakeup_from, ts FROM instant
|
|
15573
|
+
WHERE name = 'sched_wakeup' AND ref_type = 'itid'
|
|
15574
|
+
AND ref IS NOT NULL AND wakeup_from IS NOT NULL AND ts IS NOT NULL
|
|
15575
|
+
ORDER BY ref, ts DESC`
|
|
15576
|
+
);
|
|
15577
|
+
for (const row2 of rows) {
|
|
15578
|
+
if (row2.ref === null || row2.wakeup_from === null || row2.ts === null) continue;
|
|
15579
|
+
const list = wakeups.get(row2.ref);
|
|
15580
|
+
if (list === void 0) wakeups.set(row2.ref, [{ from: row2.wakeup_from, ts: row2.ts }]);
|
|
15581
|
+
else list.push({ from: row2.wakeup_from, ts: row2.ts });
|
|
15582
|
+
}
|
|
15583
|
+
const threadPid = /* @__PURE__ */ new Map();
|
|
15584
|
+
const uiThread = /* @__PURE__ */ new Map();
|
|
15585
|
+
for (const row2 of db.query(
|
|
15586
|
+
`SELECT t.id, t.name, p.pid, p.name AS process
|
|
15587
|
+
FROM thread t JOIN process p ON t.ipid = p.ipid
|
|
15588
|
+
ORDER BY t.id`
|
|
15589
|
+
)) {
|
|
15590
|
+
threadPid.set(row2.id, row2.pid);
|
|
15591
|
+
const named = row2.name === row2.process;
|
|
15592
|
+
const uiLike = row2.name !== null && (row2.name.includes("UI") || row2.name.includes("ui"));
|
|
15593
|
+
if ((named || uiLike) && !uiThread.has(row2.pid)) uiThread.set(row2.pid, row2.id);
|
|
15594
|
+
}
|
|
15595
|
+
const rsMarks = rsIpids.map(() => "?").join(", ");
|
|
15596
|
+
const unmarsh = [];
|
|
15597
|
+
for (const row2 of db.query(
|
|
15598
|
+
`SELECT c.ts, c.callid, c.name FROM callstack c
|
|
15599
|
+
JOIN thread t ON c.callid = t.id
|
|
15600
|
+
WHERE t.ipid IN (${rsMarks}) AND c.name LIKE '%UnMarsh RSTransactionData%'
|
|
15601
|
+
ORDER BY c.ts`,
|
|
15602
|
+
[...rsIpids]
|
|
15603
|
+
)) {
|
|
15604
|
+
if (row2.ts === null || row2.callid === null || row2.name === null) continue;
|
|
15605
|
+
const pid = parseUnmarshPid(row2.name);
|
|
15606
|
+
if (pid === void 0) continue;
|
|
15607
|
+
unmarsh.push({ ts: row2.ts, itid: row2.callid, pid });
|
|
15608
|
+
}
|
|
15609
|
+
return { wakeups, threadPid, uiThread, unmarsh };
|
|
15610
|
+
}
|
|
15611
|
+
function nearestWakeup(caches, itid, ts, before, after) {
|
|
15612
|
+
let best;
|
|
15613
|
+
let bestDiff = Infinity;
|
|
15614
|
+
for (const wakeup of caches.wakeups.get(itid) ?? []) {
|
|
15615
|
+
if (wakeup.ts < ts - before || wakeup.ts > ts + after) continue;
|
|
15616
|
+
const diff = Math.abs(wakeup.ts - ts);
|
|
15617
|
+
if (diff < bestDiff) {
|
|
15618
|
+
bestDiff = diff;
|
|
15619
|
+
best = wakeup;
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
return best;
|
|
15623
|
+
}
|
|
15624
|
+
function appThreadFor(caches, ipcItid, eventNs, appPid) {
|
|
15625
|
+
let current = nearestWakeup(caches, ipcItid, eventNs, WAKEUP_WINDOW_NS, WAKEUP_WINDOW_NS);
|
|
15626
|
+
for (let depth = 0; depth < MAX_CHAIN_DEPTH && current !== void 0; depth += 1) {
|
|
15627
|
+
if (caches.threadPid.get(current.from) === appPid) return current.from;
|
|
15628
|
+
current = nearestWakeup(caches, current.from, current.ts, EVENT_LOOKBACK_NS, 0);
|
|
15629
|
+
}
|
|
15630
|
+
return void 0;
|
|
15631
|
+
}
|
|
15407
15632
|
function computeRsSkip(db, opts) {
|
|
15408
15633
|
if (opts.rsIpids.length === 0) return { frames: [], totalEvents: 0 };
|
|
15409
15634
|
const rsMarks = opts.rsIpids.map(() => "?").join(", ");
|
|
@@ -15472,8 +15697,41 @@ ORDER BY c.ts`,
|
|
|
15472
15697
|
if (existing === void 0 || frame.id < existing.id) appByTs.set(frame.ts, frame);
|
|
15473
15698
|
}
|
|
15474
15699
|
const appTs = [...appByTs.keys()].sort((a, b) => a - b);
|
|
15700
|
+
const api = readApiCaches(db, opts.rsIpids);
|
|
15701
|
+
const appPidSet = /* @__PURE__ */ new Set();
|
|
15702
|
+
for (const ipid of opts.appIpids) {
|
|
15703
|
+
const row2 = db.query(
|
|
15704
|
+
"SELECT pid FROM process WHERE ipid = ? ORDER BY id LIMIT 1",
|
|
15705
|
+
[ipid]
|
|
15706
|
+
)[0];
|
|
15707
|
+
if (row2?.pid !== null && row2?.pid !== void 0) appPidSet.add(row2.pid);
|
|
15708
|
+
}
|
|
15709
|
+
const apiTrace = (frame) => {
|
|
15710
|
+
if (api === void 0) return void 0;
|
|
15711
|
+
const inWindow = api.unmarsh.filter(
|
|
15712
|
+
(event) => event.ts >= frame.ts - EVENT_LOOKBACK_NS && event.ts <= frame.ts + frame.dur
|
|
15713
|
+
);
|
|
15714
|
+
inWindow.sort((a, b) => Math.abs(a.ts - frame.ts) - Math.abs(b.ts - frame.ts) || a.ts - b.ts);
|
|
15715
|
+
let best;
|
|
15716
|
+
for (const event of inWindow.slice(0, MAX_EVENTS)) {
|
|
15717
|
+
if (!appPidSet.has(event.pid)) continue;
|
|
15718
|
+
const threadItid = appThreadFor(api, event.itid, event.ts, event.pid);
|
|
15719
|
+
if (threadItid === void 0) continue;
|
|
15720
|
+
const near = nearest(appTs, event.ts, EVENT_LOOKBACK_NS, APP_LOOKAHEAD_NS, MAX_APP_FRAMES);
|
|
15721
|
+
for (const ts of near) {
|
|
15722
|
+
const match = appByTs.get(ts);
|
|
15723
|
+
if (match === void 0 || match.itid !== threadItid) continue;
|
|
15724
|
+
const timeDiffNs = Math.abs(ts - event.ts);
|
|
15725
|
+
if (best !== void 0 && timeDiffNs >= best.timeDiffNs) continue;
|
|
15726
|
+
best = { frame: match, eventNs: event.ts, timeDiffNs, method: "rs_api" };
|
|
15727
|
+
}
|
|
15728
|
+
}
|
|
15729
|
+
return best;
|
|
15730
|
+
};
|
|
15475
15731
|
const traced = frames.map((entry) => {
|
|
15476
15732
|
const frame = entry.frame;
|
|
15733
|
+
const viaApi = apiTrace(frame);
|
|
15734
|
+
if (viaApi !== void 0) return { ...entry, traced: viaApi };
|
|
15477
15735
|
const candidates = nearest(bufferTs, frame.ts, EVENT_LOOKBACK_NS, frame.dur, MAX_EVENTS);
|
|
15478
15736
|
let best;
|
|
15479
15737
|
for (const eventNs of candidates) {
|
|
@@ -15483,7 +15741,7 @@ ORDER BY c.ts`,
|
|
|
15483
15741
|
if (best !== void 0 && timeDiffNs >= best.timeDiffNs) continue;
|
|
15484
15742
|
const match = appByTs.get(ts);
|
|
15485
15743
|
if (match === void 0) continue;
|
|
15486
|
-
best = { frame: match, eventNs, timeDiffNs };
|
|
15744
|
+
best = { frame: match, eventNs, timeDiffNs, method: "nativewindow" };
|
|
15487
15745
|
}
|
|
15488
15746
|
}
|
|
15489
15747
|
return { ...entry, ...best === void 0 ? {} : { traced: best } };
|
|
@@ -15493,6 +15751,26 @@ ORDER BY c.ts`,
|
|
|
15493
15751
|
function allFrames(db, window) {
|
|
15494
15752
|
return new FrameQuery(db).all(window);
|
|
15495
15753
|
}
|
|
15754
|
+
function instructionWaste(ctx, frames) {
|
|
15755
|
+
if (ctx.perf === void 0 || !ctx.perf.hasSamples()) return void 0;
|
|
15756
|
+
if (ctx.app.pids.length === 0) return void 0;
|
|
15757
|
+
const tracedFrames = frames.map((entry) => entry.traced?.frame).filter((frame) => frame !== void 0);
|
|
15758
|
+
if (tracedFrames.length === 0) return void 0;
|
|
15759
|
+
const firstTs = tracedFrames.reduce((min, frame) => Math.min(min, frame.ts), tracedFrames[0].ts);
|
|
15760
|
+
const lastEnd = tracedFrames.reduce(
|
|
15761
|
+
(max, frame) => Math.max(max, frame.ts + Math.max(0, frame.dur)),
|
|
15762
|
+
tracedFrames[0].ts + Math.max(0, tracedFrames[0].dur)
|
|
15763
|
+
);
|
|
15764
|
+
const index = FrameLoadIndex.build({
|
|
15765
|
+
perf: ctx.perf,
|
|
15766
|
+
pids: ctx.app.pids,
|
|
15767
|
+
range: { startNs: firstTs, endNs: lastEnd }
|
|
15768
|
+
});
|
|
15769
|
+
if (index === void 0) return void 0;
|
|
15770
|
+
let total = 0;
|
|
15771
|
+
for (const frame of tracedFrames) total += index.load(frame);
|
|
15772
|
+
return total > 0 ? total : void 0;
|
|
15773
|
+
}
|
|
15496
15774
|
function byMetricId12(a, b) {
|
|
15497
15775
|
return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
15498
15776
|
}
|
|
@@ -15586,6 +15864,37 @@ var RsSkipAnalyzer = class {
|
|
|
15586
15864
|
})
|
|
15587
15865
|
);
|
|
15588
15866
|
}
|
|
15867
|
+
const instructions = instructionWaste(ctx, result.frames);
|
|
15868
|
+
if (instructions !== void 0) {
|
|
15869
|
+
metrics.push(
|
|
15870
|
+
metric({
|
|
15871
|
+
id: "rs_skip.cpu_waste.instructions",
|
|
15872
|
+
value: instructions,
|
|
15873
|
+
unit: "count",
|
|
15874
|
+
provenance: { collector: "hiperf", table: "perf_sample", device: ctx.deviceId },
|
|
15875
|
+
fidelity: "exact",
|
|
15876
|
+
window: ctx.window
|
|
15877
|
+
})
|
|
15878
|
+
);
|
|
15879
|
+
}
|
|
15880
|
+
const byMethod = { rs_api: 0, nativewindow: 0 };
|
|
15881
|
+
for (const entry of result.frames) {
|
|
15882
|
+
if (entry.traced !== void 0) byMethod[entry.traced.method] += 1;
|
|
15883
|
+
}
|
|
15884
|
+
if (traced > 0) {
|
|
15885
|
+
for (const method of ["rs_api", "nativewindow"]) {
|
|
15886
|
+
metrics.push(
|
|
15887
|
+
metric({
|
|
15888
|
+
id: `rs_skip.traced.${method}.count`,
|
|
15889
|
+
value: byMethod[method],
|
|
15890
|
+
unit: "count",
|
|
15891
|
+
provenance: prov,
|
|
15892
|
+
fidelity: "exact",
|
|
15893
|
+
window: ctx.window
|
|
15894
|
+
})
|
|
15895
|
+
);
|
|
15896
|
+
}
|
|
15897
|
+
}
|
|
15589
15898
|
} else {
|
|
15590
15899
|
metrics.push(
|
|
15591
15900
|
metric({
|
|
@@ -15634,9 +15943,9 @@ var RsSkipAnalyzer = class {
|
|
|
15634
15943
|
appFrameId: match.frame.id,
|
|
15635
15944
|
appFrameFlag: match.frame.flag,
|
|
15636
15945
|
timeDiffMs: match.timeDiffNs / 1e6,
|
|
15637
|
-
method:
|
|
15946
|
+
method: match.method
|
|
15638
15947
|
},
|
|
15639
|
-
explain: match === void 0 ? `render_service skipped ${entry.events} frame(s) at vsync ${frame.vsync}; no app frame could be traced back to it` : `render_service skipped the frame at vsync ${frame.vsync}; ${appProcessName13(ctx)} frame ${match.frame.id} fed it (${(match.timeDiffNs / 1e6).toFixed(2)}ms from its buffer event)
|
|
15948
|
+
explain: match === void 0 ? `render_service skipped ${entry.events} frame(s) at vsync ${frame.vsync}; no app frame could be traced back to it` : `render_service skipped the frame at vsync ${frame.vsync}; ${appProcessName13(ctx)} frame ${match.frame.id} fed it ` + (match.method === "rs_api" ? `(${(match.timeDiffNs / 1e6).toFixed(2)}ms from the UnMarsh transaction)` : `(${(match.timeDiffNs / 1e6).toFixed(2)}ms from its buffer event)`),
|
|
15640
15949
|
drillDown
|
|
15641
15950
|
});
|
|
15642
15951
|
});
|
|
@@ -17918,6 +18227,7 @@ function renderFlamegraphHtml(input) {
|
|
|
17918
18227
|
].join("\n");
|
|
17919
18228
|
}
|
|
17920
18229
|
export {
|
|
18230
|
+
ANIMATION_BANDS,
|
|
17921
18231
|
BinderAnalyzer,
|
|
17922
18232
|
BinderQuery,
|
|
17923
18233
|
CATEGORY_EXTENSIONS,
|
|
@@ -17971,6 +18281,7 @@ export {
|
|
|
17971
18281
|
MAX_QUERY_LIMIT,
|
|
17972
18282
|
METRIC_DIRECTIONS,
|
|
17973
18283
|
MIN_BUFFER_PAGES,
|
|
18284
|
+
MIN_HASH_PIXELS,
|
|
17974
18285
|
MemMeasureQuery,
|
|
17975
18286
|
MemoryAnalyzer,
|
|
17976
18287
|
MemoryMeasureAnalyzer,
|
|
@@ -18005,8 +18316,10 @@ export {
|
|
|
18005
18316
|
UitestCollector,
|
|
18006
18317
|
VsyncAnalyzer,
|
|
18007
18318
|
aggregateUnreleased,
|
|
18319
|
+
analyseAnimations,
|
|
18008
18320
|
analyzeHap,
|
|
18009
18321
|
analyzeThreadWakeup,
|
|
18322
|
+
animationSeverity,
|
|
18010
18323
|
buildDepGraph,
|
|
18011
18324
|
buildHiprofilerConfig,
|
|
18012
18325
|
buildInventory,
|
|
@@ -18016,6 +18329,7 @@ export {
|
|
|
18016
18329
|
categorize,
|
|
18017
18330
|
classifyNativePath,
|
|
18018
18331
|
compareImages,
|
|
18332
|
+
compareRegion,
|
|
18019
18333
|
compareResults,
|
|
18020
18334
|
compareSceneDirs,
|
|
18021
18335
|
compareScenes,
|
|
@@ -18030,6 +18344,7 @@ export {
|
|
|
18030
18344
|
computeVsyncAnomalies,
|
|
18031
18345
|
connect,
|
|
18032
18346
|
createSceneLayout,
|
|
18347
|
+
cropRegion,
|
|
18033
18348
|
decodePng,
|
|
18034
18349
|
defaultAnalyzers,
|
|
18035
18350
|
dhash,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-perf/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|