undef1nd / sfv

Structured HTTP field values parsing and serialization. Implementation of RFC 8941 https://httpwg.org/specs/rfc8941.html
Apache License 2.0
25 stars 6 forks source link

Use criterion for benching #72

Closed Hoverbear closed 4 years ago

Hoverbear commented 4 years ago

This changes the bencher to criterion!

I noticed you don't run benches on CI, so I didn't add/change it. :) I also didn't change/add any benches, I just wanted to show you this neat library @undef1nd ! :)

Criterion is one of my favorite libraries, and I hope you might enjoy it too! If not, I won't be offended if you close this.

This uses the method described in https://bheisler.github.io/criterion.rs/book/user_guide/benchmarking_with_inputs.html to cover the existing benchmarking cases.

From reading your tests and code, it seems like you may wish to have further work deriving the benchmarks from the fixtures in tests/spec_tests?

As for why you might prefer Criterion to bencher:

parsing_list/a, abcdefghigklmnoprst, 123456785686457, 99999999999.999, (), ("somelongstringvalue" "a... time: [8.9248 us 8.9528 us 8.9827 us] change: [+75.647% +76.620% +77.587%] (p = 0.00 < 0.05) Performance has regressed. Found 5 outliers among 100 measurements (5.00%) 3 (3.00%) high mild 2 (2.00%) high severe

parsing_dict/a, dict_key2=abcdefghigklmnoprst, dict_key3=123456785686457, dict_key4=("inner-list-mem... time: [5.3266 us 5.3333 us 5.3408 us] change: [-0.3320% +0.0254% +0.3779%] (p = 0.89 > 0.05) No change in performance detected. Found 3 outliers among 100 measurements (3.00%) 2 (2.00%) high mild 1 (1.00%) high severe

serializing_item/c29tZXZlcnlsb25nc3RyaW5ndmFsdWVyZXByZXNlbnRlZGFzYnl0ZXNhbnNvbWVvdGhlcmxvbmdsaW5l time: [1.1187 us 1.1198 us 1.1210 us] change: [+0.0001% +0.1534% +0.3028%] (p = 0.05 < 0.05) Change within noise threshold. Found 2 outliers among 100 measurements (2.00%) 2 (2.00%) high mild

serializing_list/a, abcdefghigklmnoprst, 123456785686457, 99999999999.999, (), ("somelongstringvalue... time: [2.6935 us 2.7006 us 2.7074 us] change: [-1.2719% -0.8292% -0.3762%] (p = 0.00 < 0.05) Change within noise threshold.

serializing_dict/a, dict_key2=abcdefghigklmnoprst, dict_key3=123456785686457, dict_key4=("inner-list... time: [1.6210 us 1.6243 us 1.6279 us] change: [-1.4315% -0.9569% -0.5011%] (p = 0.00 < 0.05) Change within noise threshold. Found 3 outliers among 100 measurements (3.00%) 1 (1.00%) high mild 2 (2.00%) high severe



To try for yourself, install `gnuplot` (optional), then run `cargo bench` and explore `target/criterion/report`!
undef1nd commented 4 years ago

Thanks so much for doing it and explaining how it works, @Hoverbear ! Happy to merge it. 🎉