-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecode.bench.ts
More file actions
34 lines (29 loc) · 956 Bytes
/
decode.bench.ts
File metadata and controls
34 lines (29 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2025 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { expandGlob } from "@std/fs";
import { format } from "@std/fmt/bytes";
import { decode, DecodeMode } from "../src/mod.ts";
const BENCHMARKS = await (async () => {
const result = [];
for await (
const file of expandGlob("maps/*.js.map", { root: import.meta.dirname })
) {
const mapContent = Deno.readTextFileSync(file.path);
const mapJson = JSON.parse(mapContent);
result.push({
name: file.name,
mapJson,
size: mapContent.length,
});
}
return result;
})();
for (const { name, mapJson, size } of BENCHMARKS) {
Deno.bench(`${name}, lax, ${format(size)}`, () => {
decode(mapJson, { mode: DecodeMode.LAX });
});
Deno.bench(`${name}, strict, ${format(size)}`, () => {
decode(mapJson, { mode: DecodeMode.STRICT });
});
}