Closed theguy147 closed 2 years ago
Adding the solution since this was discussed on discord: Vec<i8>
is inefficient due to not being special-cased the way Vec<u8>
is (due to not matching the same type as byte reading, but this can be dealt with).
Temporary workaronud for anyone else who finds this until it's dealt with: parse as Vec<u8>
and use br(map)
to convert Vec<u8>
to Vec<i8>
.
Leaving this issue open to track the perf of Vec<i8>
. Gonna spin off another issue to ensure the performance characteristics of binrw are better documented.
I noticed today that
binrw
is very slow in comparison with a naive stdlib implementation and I'm not sure if I am doing something wrong here. In the example code belowbinrw
is approximately 170 times slower for me...Crates used:
Is there anything I am doing wrong or is that much overhead expected with this crate?
EDIT: The performance difference is especially noticeable when reading from disk (there is still a noticeable difference when using in-memory Cursors but not as much).
Sample execution:
(~160 times slower this execution but it varies)