Skip to content

Commit

Permalink
fix benchs
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGruber committed Nov 25, 2023
1 parent 02a1170 commit 6e15a2f
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions benches/lib-bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ fn soeprotocol_utils_benchmarks(c: &mut Criterion) {
let mut data_packet = DataPacket {
data: data_to_pack,
sequence: 0,
error: None,
};

c.bench_function("write_packet_data_crc", |b| {
Expand All @@ -35,7 +34,6 @@ fn soeprotocol_utils_benchmarks(c: &mut Criterion) {
let mut data_packet = DataPacket {
data: data_to_pack,
sequence: 0,
error: None,
};
c.bench_function("write_packet_data", |b| {
b.iter(|| write_packet_data(black_box(&mut wtr.to_owned()), black_box(&mut data_packet)))
Expand Down Expand Up @@ -201,8 +199,9 @@ fn soeprotocol_pack_benchmarks(c: &mut Criterion) {
)
})
});
let session_request_to_pack_object =
soeprotocol_class.get_session_request_object(session_request_to_pack.to_string());
let session_request_to_pack_object = soeprotocol_class
.get_session_request_object(session_request_to_pack.to_string())
.unwrap();
c.bench_function("session_request_pack_from_object", |b| {
b.iter(|| {
soeprotocol_class.pack_session_request_object(session_request_to_pack_object.clone())
Expand All @@ -216,8 +215,9 @@ fn soeprotocol_pack_benchmarks(c: &mut Criterion) {
)
})
});
let session_reply_to_pack_object =
soeprotocol_class.get_session_reply_object(session_reply_to_pack.to_string());
let session_reply_to_pack_object = soeprotocol_class
.get_session_reply_object(session_reply_to_pack.to_string())
.unwrap();
c.bench_function("session_reply_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_session_reply_object(session_reply_to_pack_object.clone()))
});
Expand All @@ -232,34 +232,38 @@ fn soeprotocol_pack_benchmarks(c: &mut Criterion) {
)
})
});
let outoforder_to_pack_object =
soeprotocol_class.get_ack_object(outoforder_to_pack.to_string());
let outoforder_to_pack_object = soeprotocol_class
.get_ack_object(outoforder_to_pack.to_string())
.unwrap();
c.bench_function("outoforder_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_out_of_order_object(outoforder_to_pack_object.clone()))
});
c.bench_function("ack_to_pack", |b| {
b.iter(|| soeprotocol_class.pack(SoeOpcode::Ack, black_box(ack_to_pack.to_string())))
});
let ack_to_pack_object = soeprotocol_class.get_ack_object(ack_to_pack.to_string());
let ack_to_pack_object = soeprotocol_class
.get_ack_object(ack_to_pack.to_string())
.unwrap();
c.bench_function("ack_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_ack_object(ack_to_pack_object.clone()))
});
c.bench_function("multi_to_pack", |b| {
b.iter(|| {
soeprotocol_class.pack(
SoeOpcode::MultiPacket,
black_box(multi_to_pack.to_string()),
)
soeprotocol_class.pack(SoeOpcode::MultiPacket, black_box(multi_to_pack.to_string()))
})
});
let multi_to_pack_object = soeprotocol_class.get_multi_object(multi_to_pack.to_string());
let multi_to_pack_object = soeprotocol_class
.get_multi_object(multi_to_pack.to_string())
.unwrap();
c.bench_function("multi_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_multi_object(multi_to_pack_object.clone()))
});
c.bench_function("data_to_pack", |b| {
b.iter(|| soeprotocol_class.pack(SoeOpcode::Data, black_box(data_to_pack.to_string())))
});
let data_to_pack_object = soeprotocol_class.get_data_object(data_to_pack.to_string());
let data_to_pack_object = soeprotocol_class
.get_data_object(data_to_pack.to_string())
.unwrap();
c.bench_function("data_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_data_object(data_to_pack_object.clone()))
});
Expand All @@ -271,8 +275,9 @@ fn soeprotocol_pack_benchmarks(c: &mut Criterion) {
)
})
});
let data_fragment_to_pack_object =
soeprotocol_class.get_data_object(data_fragment_to_pack.to_string());
let data_fragment_to_pack_object = soeprotocol_class
.get_data_object(data_fragment_to_pack.to_string())
.unwrap();
c.bench_function("data_fragment_to_pack_from_object", |b| {
b.iter(|| soeprotocol_class.pack_fragment_data_object(data_fragment_to_pack_object.clone()))
});
Expand Down Expand Up @@ -311,10 +316,7 @@ fn soeprotocol_pack_benchmarks(c: &mut Criterion) {
});
c.bench_function("multi_to_pack_crc", |b| {
b.iter(|| {
soeprotocol_class.pack(
SoeOpcode::MultiPacket,
black_box(multi_to_pack.to_string()),
)
soeprotocol_class.pack(SoeOpcode::MultiPacket, black_box(multi_to_pack.to_string()))
})
});
c.bench_function("data_to_pack_crc", |b| {
Expand Down

0 comments on commit 6e15a2f

Please sign in to comment.