aboutsummaryrefslogtreecommitdiff
path: root/benchmark/index.js
blob: f2e280c45934736e2e13e3e71ee6a5e000b0ec8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Bench } from "tinybench";
import { parse } from "../src/index.js";

import { readFile } from "fs/promises";

const exampleSource = await readFile("test/example.wmap", "utf-8");
const hugeSource = await readFile("test/huge.wmap", "utf-8");

const bench = new Bench({ name: "Parsing Benchmark", time: 1000 });

bench
    .add("Example map", () => {
        parse(exampleSource);
    })
    .add("Huge map", () => {
        parse(hugeSource);
    });

await bench.run();

console.log(bench.name);
console.table(bench.table());