-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guide on writing benchmarking tasks #7
Comments
I was just looking at this (and the code) to try and sort it out. I've got that you'll want to register the input types for the function with Do you have a simple example using the |
I'm officially over being ashamed that I couldn't figure out how to use this, and am now chiming in to express a similar need: My trouble going in was that I couldn't understand how (After playing with this for an hour or so I'm not confident that I can benchmark insertion into ordered and unordered collections with the tools given to me; like @heckj mentioned |
The code that provides those (built-in) generators is https://github.com/apple/swift-collections-benchmark/blob/main/Sources/CollectionsBenchmark/Benchmark/Benchmark.swift#L24-L35 They're set up create one or two sets of integers, mostly shuffled to be able to easily "work" ordered insertion algorithms. They're passed through Task (same file, just quite a bit lower) into whatever your benchmark code needs, and gives you options to test just insertion, deletions, moves, re-ordering, etc. I hope Karoy will correct me if i'm wrong, but the kit is all about two-dimension benchmarks, the measurements are always about "performance over the size/number of insertions/number of deletions/etc" - so if you're after a 1 dimensional benchmark (how long does X function take without regard to a backed collection), this isn't the right library to use. In those cases, I'd highly recommend https://github.com/ordo-one/package-benchmark - which likewise would be terrible for the use cases that this library excels at. I got quite a bit more out of reading the actual tests in swift-collections (ex: https://github.com/apple/swift-collections/blob/main/Benchmarks/Sources/Benchmarks/DequeBenchmarks.swift) - hopefully that helps ... |
We need a chapter 2 of the documentation that's all about writing benchmarks.
The
addSimple
method demonstrated in chapter 1 has no support for omitting parts of the code from the benchmarking scope, so only a fraction of benchmarks can use it.The real
add
method has support for adding setup code that isn't measured (both code that needs to be only run once per each input, and code that needs to be repeated before each measurement), but it is way too subtle to use without adequate documentation.The text was updated successfully, but these errors were encountered: