Module shortscale::extra[][src]

Conditionally-compiled for historic reference.
To include in tests and benchmarks set RUSTFLAGS=“–cfg extra”

Sample benchmarks

cargo bench on MacOS Catalina 2.6 GHz Intel Core i7

test a_shortscale                        ... bench:         239 ns/iter (+/- 20)
test b_shortscale_string_writer_no_alloc ... bench:         180 ns/iter (+/- 13)
test c_str_push                          ... bench:         239 ns/iter (+/- 28)
test d_vec_push                          ... bench:         356 ns/iter (+/- 20)
test e_display_no_alloc                  ... bench:         510 ns/iter (+/- 53)
test f_vec_concat                        ... bench:       4,571 ns/iter (+/- 426)
test g_string_join                       ... bench:       5,573 ns/iter (+/- 347)

cargo bench on GitHub Actions Ubuntu 18.04

test a_shortscale                        ... bench:         276 ns/iter (+/- 22)
test b_shortscale_string_writer_no_alloc ... bench:         256 ns/iter (+/- 10)
test c_str_push                          ... bench:         275 ns/iter (+/- 6)
test d_vec_push                          ... bench:         264 ns/iter (+/- 8)
test e_display_no_alloc                  ... bench:         640 ns/iter (+/- 53)
test f_vec_concat                        ... bench:       1,600 ns/iter (+/- 85)
test g_string_join                       ... bench:       1,754 ns/iter (+/- 9)

Structs

NumWords

Expose shortscale Display trait implementation
for easy to_string() or write!() into an existing String.

Functions

shortscale_display

Implementation writes into a pre-allocated String
using NumWords Display trait.

shortscale_str_push

Implementation pushes str’s directly into a preallocated String.

shortscale_string_join

Reimplementation of shortscale_vec_concat
Composition pushing Strings returned from functions.
This is even slower than concatenating Vecs.

shortscale_vec_concat

First Rust implementation (ever for me)
Modeled after javascript version
Functional composition by allocating and concatenating Vecs.
This is much slower than using a String builder and slower than JavaScript on MacOS.

shortscale_vec_push

Reimplementation of shortscale_str_push.
Uses Vec builder instead of String builder.
On MacOS this implementation is ~60% slower than building a String directly.
On GitHub Actions Ubuntu it is slightly faster.