Add benchmarks
Added a benchmark project using BenchmarkDotNet which measures a few scenarios on all supported runtimes. The scenarios are:
- Encoding a small integer
- Encoding a large integer
- Encoding multiple integers
The same cases are covered for decoding. The project is currently using a benchmark switcher to make space for future benchmarks, but feel free to change it to just run the one benchmark.
I've created an example optimization in this commit.
It uses a local stack-based buffer instead of a StringBuilder. Notice how the allocations are cut in half for EncodeSmall.
Before:
After:
@Genbox Could you please make a PR for this commit as well?
And also this one?
Yep. I'll get right on it. Note that the stack buffer one seems to work, but I'm unsure if the size of the buffer is enough. I did create a function that calculates the length needed before doing the work, but it was slower on a few of the platforms and didn't really save much allocation.