Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/okikio/wikitext. Event-stream based wikitext parser
Something went wrong. Try again.
wikitext parse_bench.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879/** * Benchmarks for parse orchestration and stateless end-to-end workflows. * * @module bench */// deno-lint-ignore-file no-import-prefix no-unversioned-import
import { bench, do_not_optimize, run, summary } from 'npm:mitata';
import { cycleInputs, drainStatelessLayeredWorkflow, drainStatelessParseStrictWithDiagnostics, drainStatelessParseWithDiagnostics, SAME_SIZE_MIXED_TEXT, SAME_SIZE_PATHOLOGICAL_TEXT, SAME_SIZE_PLAIN_TEXT, SYNTHETIC_ARTICLE_INPUTS, UNICODE_BENCH_FIXTURES,} from './_test_utils/perf_fixtures.ts';import { parse } from './mod.ts';
const nextSyntheticArticle = cycleInputs(SYNTHETIC_ARTICLE_INPUTS);
summary(() => { bench('parse(): same-size plain (~8 KB)', () => { do_not_optimize(parse(SAME_SIZE_PLAIN_TEXT).children.length); }).gc('inner');
bench('parse(): same-size mixed (~8 KB)', () => { do_not_optimize(parse(SAME_SIZE_MIXED_TEXT).children.length); }).gc('inner');
bench('parse(): same-size pathological (~8 KB)', () => { do_not_optimize(parse(SAME_SIZE_PATHOLOGICAL_TEXT).children.length); }).gc('inner');
bench('parseWithDiagnostics(): same-size pathological (~8 KB)', () => { do_not_optimize(drainStatelessParseWithDiagnostics(SAME_SIZE_PATHOLOGICAL_TEXT)); }).gc('inner');
bench('parseStrictWithDiagnostics(): same-size pathological (~8 KB)', () => { do_not_optimize(drainStatelessParseStrictWithDiagnostics(SAME_SIZE_PATHOLOGICAL_TEXT)); }).gc('inner');
bench('consumer workflow: stateless outline -> events -> parse (mixed ~8 KB)', () => { do_not_optimize(drainStatelessLayeredWorkflow(SAME_SIZE_MIXED_TEXT)); }).gc('inner');
bench('consumer workflow: stateless outline -> events -> parse (pathological ~8 KB)', () => { do_not_optimize(drainStatelessLayeredWorkflow(SAME_SIZE_PATHOLOGICAL_TEXT)); }).gc('inner');
for (const fixture of UNICODE_BENCH_FIXTURES) { bench(`parse(): unicode ${fixture.key} document (~8 KB)`, () => { do_not_optimize(parse(fixture.document_input).children.length); }).gc('inner'); }});
summary(() => { bench('parse(): synthetic article (~35-45 KB)', () => { do_not_optimize(parse(nextSyntheticArticle()).children.length); }).gc('inner');
bench('parseWithDiagnostics(): synthetic article (~35-45 KB)', () => { do_not_optimize(drainStatelessParseWithDiagnostics(nextSyntheticArticle())); }).gc('inner');
bench('parseStrictWithDiagnostics(): synthetic article (~35-45 KB)', () => { do_not_optimize(drainStatelessParseStrictWithDiagnostics(nextSyntheticArticle())); }).gc('inner');
bench('consumer workflow: stateless outline -> events -> parse synthetic article (~35-45 KB)', () => { do_not_optimize(drainStatelessLayeredWorkflow(nextSyntheticArticle())); }).gc('inner');});
await run();