From e35bb1b68ea3122b2987de1ee5fa9a9bb7040d29 Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 1 Dec 2025 17:30:38 +0100 Subject: [PATCH] Add Bram's day 1 benchmarks --- bram/benchmarks/bram.sh | 11 ++ bram/benchmarks/data/bram-d01-100.json | 218 +++++++++++++++++++++++++ bram/benchmarks/shell.nix | 24 +++ 3 files changed, 253 insertions(+) create mode 100644 bram/benchmarks/bram.sh create mode 100644 bram/benchmarks/data/bram-d01-100.json create mode 100644 bram/benchmarks/shell.nix diff --git a/bram/benchmarks/bram.sh b/bram/benchmarks/bram.sh new file mode 100644 index 0000000..b481092 --- /dev/null +++ b/bram/benchmarks/bram.sh @@ -0,0 +1,11 @@ +# Move to the appropriate folder +cd ../rust + +# Build binary +cargo build --release + +# Benchmark day 1 +hyperfine --warmup 5 --export-json ../benchmarks/data/bram-d01-100.json \ + --runs 100 "for run in {1..100}; do target/release/aoc2025 1; done" + +cd ../benchmarks diff --git a/bram/benchmarks/data/bram-d01-100.json b/bram/benchmarks/data/bram-d01-100.json new file mode 100644 index 0000000..05e21ea --- /dev/null +++ b/bram/benchmarks/data/bram-d01-100.json @@ -0,0 +1,218 @@ +{ + "results": [ + { + "command": "for run in {1..100}; do target/release/aoc2025 1; done", + "mean": 0.3209171330600001, + "stddev": 0.06912370514464004, + "median": 0.31733743842, + "user": 0.12774712000000002, + "system": 0.18811515, + "min": 0.18901236892, + "max": 0.5454262219200001, + "times": [ + 0.32901505492, + 0.35589986292000003, + 0.35293158192, + 0.36846902592, + 0.38234202092, + 0.30366900492, + 0.29018771692, + 0.33612383892000003, + 0.32239208392, + 0.32289456692, + 0.28245230292, + 0.26871287792, + 0.31043925992, + 0.33495310492, + 0.32918007292, + 0.34974822092, + 0.37755511792, + 0.36699618592, + 0.37780061692, + 0.38380039792, + 0.38373057992, + 0.45611059692, + 0.38467784292, + 0.38463839292, + 0.39507502192, + 0.38982799992, + 0.39220254592000003, + 0.38981040992, + 0.39322252992, + 0.39439366492, + 0.38911047592000003, + 0.40424637492, + 0.40340111592, + 0.40765913792, + 0.40841903692000003, + 0.39719493192, + 0.5454262219200001, + 0.48013536792, + 0.38111417392, + 0.35035591392, + 0.30254926192, + 0.30795329892, + 0.24643972592000002, + 0.35967777992, + 0.18901236892, + 0.21599748091999998, + 0.20967083992000002, + 0.25930284292, + 0.24317482392, + 0.30930459692, + 0.31939877792, + 0.27999646792, + 0.25791276992, + 0.23326737192000002, + 0.28325422992, + 0.26893403592, + 0.27285110192, + 0.42320354692, + 0.37206708992, + 0.39127948892000003, + 0.30741866992, + 0.32723120392, + 0.26509262392, + 0.31527609892, + 0.32005553492, + 0.19529146892, + 0.25337454192, + 0.25479495492, + 0.28464836992, + 0.28461546792, + 0.29561398892, + 0.24718056092000001, + 0.26281247592, + 0.27454682192, + 0.26249891392, + 0.29358589892, + 0.27614823592, + 0.43836924992000004, + 0.23460257892000003, + 0.21493214292, + 0.19987172792000002, + 0.27299085992, + 0.19212104691999998, + 0.34766739992, + 0.40541196492000003, + 0.40074627692000003, + 0.37993838792, + 0.27619252392, + 0.32962238392, + 0.29411795592, + 0.23638225192, + 0.26090372492, + 0.25797784692, + 0.28363530592, + 0.25150928992, + 0.32068586392, + 0.36486215392, + 0.26354788392, + 0.27554843892, + 0.24832705991999998 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ] + } + ] +} diff --git a/bram/benchmarks/shell.nix b/bram/benchmarks/shell.nix new file mode 100644 index 0000000..41f79e6 --- /dev/null +++ b/bram/benchmarks/shell.nix @@ -0,0 +1,24 @@ +let + pkgs = import {}; +in pkgs.mkShell { + packages = with pkgs; [ + # Benchmarking tool + hyperfine + + # Jupyter notebook + (python312.withPackages + (py-pkgs: with py-pkgs; [ + notebook + pip-chill + ]) + ) + ]; + + # Rust installation + nativeBuildInputs = with pkgs; [ rustc cargo gcc rustfmt clippy valgrind ]; + + # Certain Rust tools won't work without this + # This can also be fixed by using oxalica/rust-overlay and specifying the rust-src extension + # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. for more details. + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; +} \ No newline at end of file