The benchmark BlockToJsonVerbose
only tests generating (and destroying)
the JSON data structure, but serializing into a string is also a
performance critical aspect of the RPC calls.
Extracts test setup into a struct TestBlockAndIndex
, and uses it in
both BlockToJsonVerbose
and BlockToJsonVerboseWrite
.
Also, use ankerl::nanobench::doNotOptimizeAway
to make sure the compiler
can’t optimize the result of the calls away.
Here are benchmark results on my Intel i7-8700:
ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark |
---|---|---|---|---|---|---|---|---|---|
71,807,017.00 | 13.93 | 0.4% | 555,782,961.00 | 220,788,645.00 | 2.517 | 102,279,341.00 | 0.4% | 0.80 | BlockToJsonVerbose |
27,916,835.00 | 35.82 | 0.1% | 235,084,034.00 | 89,033,525.00 | 2.640 | 42,911,139.00 | 0.3% | 0.32 | BlockToJsonVerboseWrite |