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.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { test } from 'vitest';
|
|
import assert from 'node:assert/strict';
|
|
import { parseBenchmarkArgs } from './args.ts';
|
|
|
|
test('an empty command line keeps the default round count', () => {
|
|
assert.deepEqual(parseBenchmarkArgs([]), {
|
|
rounds: 5,
|
|
jsonPath: undefined,
|
|
captureFiles: [],
|
|
});
|
|
});
|
|
|
|
test('rounds, json path, and every capture file are read from their flags', () => {
|
|
assert.deepEqual(
|
|
parseBenchmarkArgs([
|
|
'--rounds',
|
|
'9',
|
|
'--json',
|
|
'out/bench.json',
|
|
'--file',
|
|
'a.png',
|
|
'--file',
|
|
'b.png',
|
|
]),
|
|
{ rounds: 9, jsonPath: 'out/bench.json', captureFiles: ['a.png', 'b.png'] },
|
|
);
|
|
});
|
|
|
|
test('a round count that is not a positive number falls back to the default', () => {
|
|
assert.equal(parseBenchmarkArgs(['--rounds', '0']).rounds, 5);
|
|
assert.equal(parseBenchmarkArgs(['--rounds', 'many']).rounds, 5);
|
|
assert.equal(parseBenchmarkArgs(['--rounds', '2.4']).rounds, 2);
|
|
});
|
|
|
|
test('a flag with no value after it is ignored', () => {
|
|
assert.deepEqual(parseBenchmarkArgs(['--json']), {
|
|
rounds: 5,
|
|
jsonPath: undefined,
|
|
captureFiles: [],
|
|
});
|
|
});
|