mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
aquatic_http: serialize responses to a buffer ref instead of new vec
This improves benchmark performance somewhat and performance during load testing a bit too.
This commit is contained in:
parent
228511b3aa
commit
fd68a5f603
7 changed files with 1101 additions and 1089 deletions
|
|
@ -26,9 +26,14 @@ pub fn bench(c: &mut Criterion) {
|
|||
|
||||
let response = Response::Announce(announce_response);
|
||||
|
||||
c.bench_function("announce-response-to-bytes", |b| b.iter(||
|
||||
Response::to_bytes(black_box(&response))
|
||||
));
|
||||
let mut buffer = [0u8; 4096];
|
||||
let mut buffer = ::std::io::Cursor::new(&mut buffer[..]);
|
||||
|
||||
c.bench_function("announce-response-to-bytes", |b| b.iter(|| {
|
||||
buffer.set_position(0);
|
||||
|
||||
Response::write(black_box(&response), black_box(&mut buffer)).unwrap();
|
||||
}));
|
||||
}
|
||||
|
||||
criterion_group!{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue