Skip to content

Commit 0adb3a2

Browse files
committed
Add encoder benchmark
1 parent 378003f commit 0adb3a2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

bench/encode.bench.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import { expandGlob } from "jsr:@std/fs";
6+
import { format } from "jsr:@std/fmt/bytes";
7+
8+
import { decode, encode } from "../mod.ts";
9+
10+
const BENCHMARKS = await (async () => {
11+
const result = [];
12+
for await (
13+
const file of expandGlob("*.js.map", { root: import.meta.dirname })
14+
) {
15+
const mapContent = Deno.readTextFileSync(file.path);
16+
const mapJson = JSON.parse(mapContent);
17+
const info = decode(mapJson);
18+
result.push({
19+
name: file.name,
20+
info,
21+
size: mapContent.length,
22+
});
23+
}
24+
return result;
25+
})();
26+
27+
for (const { name, info, size } of BENCHMARKS) {
28+
Deno.bench(`${name}, ${format(size)}`, () => {
29+
encode(info);
30+
});
31+
}

0 commit comments

Comments
 (0)