Skip to content

Commit d39a435

Browse files
committed
Add some basic decoding benchmark
1 parent 4548898 commit d39a435

12 files changed

+54
-22
lines changed

bench/common-formatted.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/common.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/decode.bench.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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, DecodeMode } from "../mod.ts";
9+
10+
const BENCHMARKS = await (async () => {
11+
const result = [];
12+
for await (const file of expandGlob("*.js.map", { root: import.meta.dirname })) {
13+
const mapContent = Deno.readTextFileSync(file.path);
14+
const mapJson = JSON.parse(mapContent);
15+
result.push({
16+
name: file.name,
17+
mapJson,
18+
size: mapContent.length,
19+
});
20+
}
21+
return result;
22+
})();
23+
24+
for (const {name, mapJson, size} of BENCHMARKS) {
25+
Deno.bench(`${name}, lax, ${format(size)}`, () => {
26+
decode(mapJson, { mode: DecodeMode.LOOSE });
27+
});
28+
29+
Deno.bench(`${name}, strict, ${format(size)}`, () => {
30+
decode(mapJson, { mode: DecodeMode.STRICT });
31+
});
32+
}

bench/sdk-formatted.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/sdk.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/simple-formatted.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/simple.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/typescript-formatted.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bench/typescript.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno.lock

Lines changed: 11 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)