mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
9aa6465768
* perf(scripts): add a device-free PNG crop benchmark `pnpm bench:png-crop` runs the whole-image pipeline and the shipped region crop over the same bytes in one process, so the comparison holds the capture content, the deflate stream, and the machine fixed. The corpus is generated, which keeps a run at seconds with no device; real captures join the same table via `--file`, and each corpus entry prints its compressed size so an unrealistic corpus is visible. The README records what the measurements said, including the case the encoder policy loses: `None` on every scanline is faster everywhere but writes about 1.7x more bytes than a filtered encoding on smooth low-frequency content. * chore(gates): run the PNG crop benchmark's model tests in unit-core Registers scripts/png-crop-benchmark/*.test.ts so the timing summary that the report is built from stays covered without a device lane.
21 lines
702 B
TypeScript
21 lines
702 B
TypeScript
import { test } from 'vitest';
|
|
import assert from 'node:assert/strict';
|
|
import { speedup, summarize } from './statistics.ts';
|
|
|
|
test('summarize reports the middle of an odd sample set', () => {
|
|
assert.deepEqual(summarize([9, 1, 5]), { medianMs: 5, bestMs: 1, worstMs: 9 });
|
|
});
|
|
|
|
test('summarize averages the two middle samples of an even set', () => {
|
|
assert.equal(summarize([4, 8, 2, 6]).medianMs, 5);
|
|
});
|
|
|
|
test('summarize survives an empty sample set', () => {
|
|
assert.deepEqual(summarize([]), { medianMs: 0, bestMs: 0, worstMs: 0 });
|
|
});
|
|
|
|
test('speedup expresses the old pipeline in multiples of the new one', () => {
|
|
assert.equal(speedup(120, 40), 3);
|
|
assert.equal(speedup(120, 0), 0);
|
|
});
|