From 43f69a0ee344f180685cc2fb7ee75bad885211a9 Mon Sep 17 00:00:00 2001 From: merrywhether Date: Fri, 6 Dec 2024 15:09:46 -0800 Subject: [PATCH] add timing --- src/00/main.ts | 2 ++ src/01/main.ts | 7 +++++-- src/02/main.ts | 3 +++ src/03/main.ts | 3 +++ src/04/main.ts | 3 +++ src/05/main.ts | 3 +++ src/06/main.ts | 3 +++ 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/00/main.ts b/src/00/main.ts index 2ae023c..8b2ab79 100644 --- a/src/00/main.ts +++ b/src/00/main.ts @@ -6,5 +6,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/01/main.ts b/src/01/main.ts index 310be33..7aca018 100644 --- a/src/01/main.ts +++ b/src/01/main.ts @@ -1,6 +1,7 @@ // { distance: 3246517, similiarity: 29379307 } +// Elapsed: 3ms -export async function main(target: string) { +export async function main(target = "input") { const dirpath = new URL(".", import.meta.url).pathname; const text = await Deno.readTextFile(`${dirpath}/${target}.txt`); @@ -30,5 +31,7 @@ export async function main(target: string) { } if (import.meta.main) { - console.log(await main("input")); + const startTime = performance.now(); + console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/02/main.ts b/src/02/main.ts index d2a6f7a..3ff809d 100644 --- a/src/02/main.ts +++ b/src/02/main.ts @@ -1,4 +1,5 @@ // { safeLines: 660, dampenedSafeLines: 689 } +// Elapsed: 3ms export async function main(target = "input") { const dirpath = new URL(".", import.meta.url).pathname; @@ -51,5 +52,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/03/main.ts b/src/03/main.ts index b5c18e5..a4173b2 100644 --- a/src/03/main.ts +++ b/src/03/main.ts @@ -1,4 +1,5 @@ // { doQuotientSum: 76911921, quotientSum: 163931492 } +// Elapsed: 4ms // fun with eval()! (this signature is found in the input so we use it directly instead of parsing and reconstructing) // deno-lint-ignore no-unused-vars @@ -35,5 +36,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/04/main.ts b/src/04/main.ts index 47f943d..9e08cb5 100644 --- a/src/04/main.ts +++ b/src/04/main.ts @@ -1,4 +1,5 @@ // { wordCount: 2718, xCount: 2046 } +// Elapsed: 6ms const wordTarget = "XMAS"; @@ -94,5 +95,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/05/main.ts b/src/05/main.ts index af1e35a..78a2af3 100644 --- a/src/05/main.ts +++ b/src/05/main.ts @@ -1,4 +1,5 @@ // { legalUpdateMiddlePageSum: 5955, fixedUpdateMiddlePageSum: 4030 } +// Elapsed: 11ms export async function main(target = "input") { const dirpath = new URL(".", import.meta.url).pathname; @@ -65,5 +66,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); } diff --git a/src/06/main.ts b/src/06/main.ts index 7415ba8..f6db4dc 100644 --- a/src/06/main.ts +++ b/src/06/main.ts @@ -1,4 +1,5 @@ // { positionCount: 5312, loopCount: 1748 } +// Elapsed: 435ms type Direction = "y" | "-y" | "x" | "-x"; @@ -114,5 +115,7 @@ export async function main(target = "input") { } if (import.meta.main) { + const startTime = performance.now(); console.log(await main()); + console.log(`Elapsed: ${Math.round(performance.now() - startTime)}ms`); }