Skip to content

Create "bytesbuf vs bytes" benchmark for read/write operations #151

@sandersaares

Description

@sandersaares

In the bytesbuf crate, we have the BytesBuf and BytesView types. These implement inherent functions for reading/writing bytes (found in buf_put.rs and view_get.rs), as well as the Buf and BufMut traits from the bytes crate (via contents of bytes_compat folder), which offer similar default-implemented methods for reading/writing bytes.

Our benchmarks currently only test the inherent functions, and only a subset of these.

Create a thorough benchmark suite for comparing the two implementations, which we can use to prove that our inherent implementations do not accidentally cause performance regressions. Include all inherent read/write functions in the two files mentioned above. Include all read/write functions found on Buf and BytesBuf.

This will be a new benchmark file, bytesbuf/benches/bytesbuf_vs_bytes.rs. It will contain multiple benchmark groups: get, put, get_num and put_num. Both the bytesbuf and the bytes functions will be part of the same group, so they can be easily compared in the output (e.g. we will have both get_u64_bytesbuf and get_u64_bytes benchmarks in the get_num group).

The purpose for having _num groups is that the numeric get/put functions are very fast, whereas some others (like reading/writing entire byte slices or byte sequences) are slower. For ease of comparison, each group should only contain functions of similar expected duration, so we put all the (extremely fast) numeric value reading/writing in its own benchmark group.

Follow patterns used in existing bytesbuf benchmarks. Include memory allocation measurement via alloc_tracker, so we can prove that we do not accidentally allocate more memory than bytes.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions