From 97e901ee199188718718cbca15a48a89c8592a90 Mon Sep 17 00:00:00 2001 From: Ty Date: Mon, 11 Dec 2023 00:16:11 -0700 Subject: [PATCH] Fix benchmark status + more WASM hell also cors is dum --- cli/src/main.rs | 2 +- wasm/Cargo.toml | 2 +- wasm/index.html | 49 +++++++++++++++++++++++++++++++++++++++++++------ wasm/src/lib.rs | 11 +++++++++-- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 883966b..f8c8cc1 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -147,7 +147,7 @@ async fn main() { let end = Instant::now(); timings.push(end - start); - print!("\r{:.2}%", ((i - warmup) as f32 / n as f32) * 100.0); + print!("\r{:.2}%", (i as f32 / (n + warmup) as f32) * 100.0); let _ = std::io::stdout().flush(); } timings.drain(..=(warmup as usize)); diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 5851740..a94632e 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -10,5 +10,5 @@ crate-type = ["cdylib", "rlib"] [dependencies] wasm-bindgen = "0.2.84" wasm-bindgen-futures = "0.4.39" -console_error_panic_hook = { version = "0.1.7", optional = true } +console_error_panic_hook = { version = "0.1.7" } advent = { path = "../lib" } \ No newline at end of file diff --git a/wasm/index.html b/wasm/index.html index 71cb911..0d38d19 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -1,12 +1,49 @@ - + + + + +
+
+ + +
+
+ +
+

Day 1:

+

Day 2:

+

Day 3:

+

Day 4:

+

Day 5:

+

Day 6:

+

Day 7:

+

Day 8:

+

Day 9:

+

Day 10:

+

Day 11:

+
+ \ No newline at end of file diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index 85a2e7b..72d87de 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -1,6 +1,13 @@ use wasm_bindgen::prelude::*; +// #[wasm_bindgen] +// extern "C" { +// fn alert(s: &str); +// } + #[wasm_bindgen] -pub async fn solve(day: u8, part: u8, auth: String) -> String { - advent::get_day(day, advent::fetcher::fetch_input(auth, day).await).solve(part, false) +pub fn solve(day: u8, part: u8, input: String) -> String { + console_error_panic_hook::set_once(); + + advent::get_day(day, input).solve(part, false) }