Skip to content

Commit 2f05228

Browse files
committed
add timings
1 parent ca06991 commit 2f05228

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

build/build.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const BUILD_OPTIONS: ESBuild.BuildOptions = {
1111
};
1212

1313
if (import.meta.main) {
14+
const start = performance.now();
1415
await Dictionary.build();
1516
await ESBuild.build(BUILD_OPTIONS);
17+
const end = performance.now();
18+
// deno-lint-ignore no-console
19+
console.log(`Total time took: ${Math.floor(end - start)}ms`);
1620
}

dictionary/build.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ const DESTINATION = new URL("./dictionary.ts", import.meta.url);
88
export async function build(): Promise<void> {
99
// deno-lint-ignore no-console
1010
console.log("Building dictionary...");
11+
const start = performance.now();
1112
const text = await Deno.readTextFile(SOURCE);
13+
const startDictionary = performance.now();
14+
const dictionary = parseDictionary(text);
15+
const endDictionary = performance.now();
1216
const json = JSON.stringify(
13-
Object.fromEntries(parseDictionary(text)),
17+
Object.fromEntries(dictionary),
1418
undefined,
1519
2,
1620
);
@@ -22,8 +26,13 @@ import { Dictionary } from "./type.ts";
2226
export const dictionary: Dictionary = new Map(Object.entries(${json}));
2327
`;
2428
await Deno.writeTextFile(DESTINATION, code);
29+
const end = performance.now();
30+
const total = Math.floor(end - start);
31+
const parsing = Math.floor(endDictionary - startDictionary);
2532
// deno-lint-ignore no-console
26-
console.log("Building dictionary done");
33+
console.log(
34+
`Building dictionary done in ${total}ms (parsing dictionary took ${parsing}ms)`,
35+
);
2736
}
2837
if (import.meta.main) {
2938
await build();

0 commit comments

Comments
 (0)