27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
/**
|
|
* R0 measurement: served size of the module and instantiate time (D-R13 budget, enforced
|
|
* from R2 on the real core; R0 records the skeleton's numbers).
|
|
*/
|
|
import { readFileSync } from 'node:fs'
|
|
import { gzipSync } from 'node:zlib'
|
|
|
|
import { coreWasmPath, loadCore } from '../src/index'
|
|
import { coreBuilt } from './helpers/core'
|
|
|
|
/** D-R13: the served module (compressed) stays under this many bytes. */
|
|
const COMPRESSED_BUDGET_BYTES = 600_000
|
|
|
|
describe.skipIf(!coreBuilt)('module size and instantiate time (wasm)', () => {
|
|
it('stays under the compressed budget and reports its numbers', async () => {
|
|
const bytes = readFileSync(coreWasmPath())
|
|
const gzip = gzipSync(bytes, { level: 9 }).length
|
|
const started = performance.now()
|
|
await loadCore()
|
|
const instantiateMs = performance.now() - started
|
|
console.info(
|
|
`[core-wasm] faunosteo_wasm_bg.wasm: ${bytes.length} bytes raw, ${gzip} bytes gzip-9, instantiate ${instantiateMs.toFixed(1)} ms`,
|
|
)
|
|
expect(gzip).toBeLessThanOrEqual(COMPRESSED_BUDGET_BYTES)
|
|
})
|
|
})
|