fspoettel / advent-of-code-rust

🎄Starter template for solving Advent of Code in Rust.
MIT License
638 stars 43 forks source link

Being able to store benchmarking metrics #24

Closed NangiDev closed 1 year ago

NangiDev commented 1 year ago

I had this idea of trying to store benchmarks in a file when running them with a specific command.

example on command: cargo bm 02 My cargo .config

That would call on a rust binary that runs the benchmarking command with --release flag and stores it into a txt-file.

I started on the feature here My attempt

But could not really finish it in a smart and reliable way.

The idea is that inside /src/benchmarks/table.txt should contain a line per day. Containing Day, latest and best score for both parts.

Ex: 01 L1:85.40µs B185.40µs L2:74.10µs B2:74.10µs first being the day (01). L1 being latest part 1 and B1 being best part 1 and so on. My table so far

I'm pretty new at Rust so I think I sort of tangled myself into a weird mess. My biggest problem is how to replace and update the correct line of the file.

What do you think? Anyone have a better and simpler way of doing this? Is it even valuable?

fspoettel commented 1 year ago

Hey! We were discussing this in #16 already so I think this is a valuable feature to add!

I implemented a proof of concept on my 2022 repo (see here for output). I reworked the benchmarking a bit to take more samples, see here for how this works and what it looks like.

I can't access your repo for some reason - once your links are accessible, it would be cool to compare implementations and see how we can bring this to the everyone. 💪

NangiDev commented 1 year ago

Awesome! Looks much better and very much like something I would want.

The repo was of course private. I made it public so you should be able to see it now.

My Rust skills aren't that good, so I don't think my solution has that much to keep, but maybe it gives you some ideas. The reason why I posted it was to make sure I'm not spending tons of time on something someone else can create faster. And turns out you even have had a separate discussion about it.

This template is really nice working with 👍 thanks!

PS: I saw this Youtuber fetching the example input somehow 🤔 so that should be possible

Edit: I did quick test on one way of fetching example input. Gist It's not perfect because it highly depends on the text in puzzle description being typed in a particular way. It works for all (1-7) puzzles release so far this year (2022)

fspoettel commented 1 year ago

I extracted the idea for fetching example inputs to #26