benchy
benchy copied to clipboard
Issue #6 Ability to use the timings in the code
- fixed some formatting, a minor bug and removed the unused dots proc
- added new feature to capture data instead of printing, with tests and readme update
Your first part about formatting looks great.
I am not sure about BenchyData. I'll think about this. I don't want to make anything more complex then it needs to.
Just a proposition. The feature would be nice to have in general I think, though, since it gives the user the opportunity to calculate other statistical values, save the data to a file or print it in a different way. Making a little change but making this lib a lot more generic. Also this implementation leaves your previous API intact.
About the BenchyData
type:
The type was just an attempt to gather all relevant data in an object. Naming, typing, and what data is inside is kinda up to preference. You could keep it simple and just pass type Deltas*: seq[float64]
. You could also make another timeIt
overload that uses Deltas
instead of BenchyData
. I just figured I might as well make use of the functionality you already wrote.
About passing BenchyData
:
Since you can't just return the data from a template (I think?), I couldn't come up with a better way to get the data out of template, than passing in a var
. The other idea was to use and export a global variable in benchy.nim
. That is even more cryptic to use, though.
Frankly my experience with templates is limited, this was the first time working with them at all. Probably you could make something way more convenient with macros, but I don't know them yet.
Offtopic: I watched your talk on fosdem this year and was pretty impressed with your work in the nim landscape. I hope I don't get on your nerves with asking this. You talked in some gh issues about making a fidget 2. You mind sharing how your progress on that is? Looking forward to it.
I reworked it to just take an openArray[float64]
instead of benchyData
. You're right (if that's what you meant), that makes it a lot cleaner.