diff options
Diffstat (limited to 'benchmark/index.js')
| -rw-r--r-- | benchmark/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/benchmark/index.js b/benchmark/index.js new file mode 100644 index 0000000..e2bae6d --- /dev/null +++ b/benchmark/index.js @@ -0,0 +1,21 @@ +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()); |