Skip to content

Commit

Permalink
add timing
Browse files Browse the repository at this point in the history
  • Loading branch information
merrywhether committed Dec 6, 2024
1 parent c568b4b commit 43f69a0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/00/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
7 changes: 5 additions & 2 deletions src/01/main.ts
Original file line number Diff line number Diff line change
@@ -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`);

Expand Down Expand Up @@ -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`);
}
3 changes: 3 additions & 0 deletions src/02/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// { safeLines: 660, dampenedSafeLines: 689 }
// Elapsed: 3ms

export async function main(target = "input") {
const dirpath = new URL(".", import.meta.url).pathname;
Expand Down Expand Up @@ -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`);
}
3 changes: 3 additions & 0 deletions src/03/main.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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`);
}
3 changes: 3 additions & 0 deletions src/04/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// { wordCount: 2718, xCount: 2046 }
// Elapsed: 6ms

const wordTarget = "XMAS";

Expand Down Expand Up @@ -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`);
}
3 changes: 3 additions & 0 deletions src/05/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// { legalUpdateMiddlePageSum: 5955, fixedUpdateMiddlePageSum: 4030 }
// Elapsed: 11ms

export async function main(target = "input") {
const dirpath = new URL(".", import.meta.url).pathname;
Expand Down Expand Up @@ -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`);
}
3 changes: 3 additions & 0 deletions src/06/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// { positionCount: 5312, loopCount: 1748 }
// Elapsed: 435ms

type Direction = "y" | "-y" | "x" | "-x";

Expand Down Expand Up @@ -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`);
}

0 comments on commit 43f69a0

Please sign in to comment.