perdumonocle / sql-builder

Simple SQL code generator.
MIT License
123 stars 13 forks source link

Add basic benchmarks #7

Closed ljoonal closed 3 years ago

ljoonal commented 3 years ago

Some really basic benches comparing sql-builder vs string concatenation & format!() performance.

I initially made them just for my own curiosity, but I thought that I'd at least offer to open a PR for these since someone else might find it interesting too, even if the results might not be too meaningful or useful.

They don't run on stable rust though since test seems to still be experimental, but on nightly cargo bench works fine to show the results.

For anyone who but is interested in the results but too lazy to run the benches themselves: on my ryzen1700x machine I got the following results:

test insert_builder       ... bench:     118,098 ns/iter (+/- 3,382)
test insert_string_concat ... bench:      13,747 ns/iter (+/- 282)
test insert_string_format ... bench:       5,488 ns/iter (+/- 62)

test join_select_builder ... bench:         856 ns/iter (+/- 23)
test join_select_string  ... bench:          13 ns/iter (+/- 0)

test simple_select_builder       ... bench:      69,097 ns/iter (+/- 14,267)
test simple_select_string_concat ... bench:       9,831 ns/iter (+/- 2,175)
test simple_select_string_format ... bench:       4,732 ns/iter (+/- 81)

test static_select_builder ... bench:         342 ns/iter (+/- 28)
test static_select_string  ... bench:          12 ns/iter (+/- 0)