Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 19d1bf2

Browse files
author
rainliu
committed
fix bench
1 parent 4a6c57f commit 19d1bf2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

benches/packet_bench.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ fn benchmark_packet(c: &mut Criterion) {
2424
payload: Bytes::from_static(&[0xFFu8; 15]), //vec![0x07, 0x08, 0x09, 0x0a], //MTU=1500
2525
..Default::default()
2626
};
27-
let mut raw = BytesMut::new();
28-
let _ = pkt.marshal_to(&mut raw).unwrap();
29-
let raw = raw.freeze();
27+
let raw = pkt.marshal().unwrap();
3028
let buf = &mut raw.clone();
3129
let p = Packet::unmarshal(buf).unwrap();
3230
if pkt != p {
@@ -38,9 +36,9 @@ fn benchmark_packet(c: &mut Criterion) {
3836

3937
///////////////////////////////////////////////////////////////////////////////////////////////
4038
let mut buf = BytesMut::with_capacity(pkt.marshal_size());
39+
buf.resize(pkt.marshal_size(), 0);
4140
c.bench_function("Benchmark MarshalTo", |b| {
4241
b.iter(|| {
43-
buf.clear();
4442
let _ = pkt.marshal_to(&mut buf).unwrap();
4543
})
4644
});

0 commit comments

Comments
 (0)