/** * D-R13 budget: the served module (gzip) stays under 600 KB; the numbers are printed for * RUST.md (raw and compressed size, compile + instantiate time on Node). */ import { readFileSync } from 'node:fs' import { gzipSync } from 'node:zlib' import { CoreRuntime } from '../src/index' import { coreWasmPath, nodeCoreSource } from '../src/node' /** D-R13: the served module (compressed) stays under this many bytes. */ const COMPRESSED_BUDGET_BYTES = 600_000 describe('module size and instantiate time (shipped wasm build)', () => { it('stays under the compressed budget and reports its numbers', async () => { const bytes = readFileSync(coreWasmPath('pkg')) const gzip = gzipSync(bytes, { level: 9 }).length const started = performance.now() const runtime = new CoreRuntime(nodeCoreSource('pkg')) expect(await runtime.ready()).toBe(true) const readyMs = performance.now() - started console.info( `[core-wasm] faunosteo_wasm_bg.wasm: ${bytes.length} bytes raw, ${gzip} bytes gzip-9, compile + instantiate ${readyMs.toFixed(1)} ms`, ) expect(gzip).toBeLessThanOrEqual(COMPRESSED_BUDGET_BYTES) }) })