mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: add criterion benchmark for announce response to bytes
Speedup of custom implementation compared to using bendy: announce-response-to-bytes: time: [413.77 ns 415.34 ns 417.08 ns] change: [-93.074% -93.021% -92.968%] (p = 0.00 < 0.01) Performance has improved.
This commit is contained in:
parent
9df1f0ecc6
commit
4caf174da5
13 changed files with 2064 additions and 0 deletions
|
|
@ -18,6 +18,11 @@ name = "bench_request_from_path"
|
||||||
path = "benches/bench_request_from_path.rs"
|
path = "benches/bench_request_from_path.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "bench_announce_response_to_bytes"
|
||||||
|
path = "benches/bench_announce_response_to_bytes.rs"
|
||||||
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
|
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
|
||||||
|
|
|
||||||
42
aquatic_http/benches/bench_announce_response_to_bytes.rs
Normal file
42
aquatic_http/benches/bench_announce_response_to_bytes.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
use std::net::Ipv4Addr;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use aquatic_http::protocol::response::*;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn bench(c: &mut Criterion) {
|
||||||
|
let mut peers = Vec::new();
|
||||||
|
|
||||||
|
for i in 0..100 {
|
||||||
|
peers.push(ResponsePeer {
|
||||||
|
ip_address: Ipv4Addr::new(127, 0, 0, i),
|
||||||
|
port: i as u16
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let announce_response = AnnounceResponse {
|
||||||
|
announce_interval: 120,
|
||||||
|
complete: 100,
|
||||||
|
incomplete: 500,
|
||||||
|
peers: ResponsePeerListV4(peers),
|
||||||
|
peers6: ResponsePeerListV6(Vec::new()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = Response::Announce(announce_response);
|
||||||
|
|
||||||
|
c.bench_function("announce-response-to-bytes", |b| b.iter(||
|
||||||
|
Response::to_bytes(black_box(&response))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!{
|
||||||
|
name = benches;
|
||||||
|
config = Criterion::default()
|
||||||
|
.sample_size(1000)
|
||||||
|
.measurement_time(Duration::from_secs(180))
|
||||||
|
.significance_level(0.01);
|
||||||
|
targets = bench
|
||||||
|
}
|
||||||
|
criterion_main!(benches);
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"group_id":"announce-response-to-bytes","function_id":null,"value_str":null,"throughput":null,"full_id":"announce-response-to-bytes","directory_name":"announce-response-to-bytes","title":"announce-response-to-bytes"}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":6033.211414448978,"upper_bound":6077.812796004471},"point_estimate":6054.625623439862,"standard_error":11.387162302248655},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":5978.799232230455,"upper_bound":6005.189535363421},"point_estimate":5992.745967541798,"standard_error":6.185398365563177},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":157.08470879401094,"upper_bound":190.1634482791119},"point_estimate":175.51713287349847,"standard_error":8.3821979113297},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":6052.909623777413,"upper_bound":6106.324900686703},"point_estimate":6078.257114077077,"standard_error":13.648790489926581},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":285.8045348063516,"upper_bound":442.7497149360172},"point_estimate":363.44843558752416,"standard_error":40.16921333191484}}
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
||||||
|
[5184.137608004838,5534.60305616611,6469.177584596171,6819.643032757444]
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"group_id":"announce-response-to-bytes","function_id":null,"value_str":null,"throughput":null,"full_id":"announce-response-to-bytes","directory_name":"announce-response-to-bytes","title":"announce-response-to-bytes"}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":419.88612634751735,"upper_bound":425.38508524104503},"point_estimate":422.5234574675309,"standard_error":1.4143626861263792},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":411.1840254440792,"upper_bound":413.2648196433366},"point_estimate":412.0626077394812,"standard_error":0.539288755707038},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":11.914005345139904,"upper_bound":13.958948147472947},"point_estimate":12.859769956741538,"standard_error":0.5147456144787788},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":413.760828155085,"upper_bound":417.06705955616684},"point_estimate":415.33960474085285,"standard_error":0.844822382993726},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":37.145365634474445,"upper_bound":51.978453081812695},"point_estimate":44.61780477344027,"standard_error":3.780806408623577}}
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
||||||
|
[351.7895769512653,377.8892152978113,447.4882508886006,473.5878892351466]
|
||||||
7
scripts/criterion/aquatic-http-announce-response-to-bytes.sh
Executable file
7
scripts/criterion/aquatic-http-announce-response-to-bytes.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Compare against latest. If you commit changes, replace "latest" directory
|
||||||
|
# with "new" directory after running benchmark.
|
||||||
|
|
||||||
|
export RUSTFLAGS="-C target-cpu=native"
|
||||||
|
|
||||||
|
cargo bench --bench bench_announce_response_to_bytes -- --noplot --baseline latest
|
||||||
Loading…
Add table
Add a link
Reference in a new issue