mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: add criterion benchmarks for request from path parsing
About 35% improvement by using both memchr methods
This commit is contained in:
parent
9b0956cc91
commit
a8e355f22a
17 changed files with 2441 additions and 5 deletions
|
|
@ -13,6 +13,11 @@ path = "src/lib/lib.rs"
|
|||
name = "aquatic_http"
|
||||
path = "src/bin/main.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "bench_request_from_path"
|
||||
path = "benches/bench_request_from_path.rs"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
|
||||
|
|
@ -37,5 +42,6 @@ serde = { version = "1", features = ["derive"] }
|
|||
simplelog = "0.8"
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
quickcheck = "0.9"
|
||||
quickcheck_macros = "0.9"
|
||||
|
|
|
|||
24
aquatic_http/benches/bench_request_from_path.rs
Normal file
24
aquatic_http/benches/bench_request_from_path.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use std::time::Duration;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
use aquatic_http::protocol::request::Request;
|
||||
|
||||
|
||||
static INPUT: &str = "/announce?info_hash=%04%0bkV%3f%5cr%14%a6%b7%98%adC%c3%c9.%40%24%00%b9&peer_id=-TR2940-5ert69muw5t8&port=11000&uploaded=0&downloaded=0&left=0&numwant=0&key=3ab4b977&compact=1&supportcrypto=1&event=stopped";
|
||||
|
||||
|
||||
pub fn bench(c: &mut Criterion) {
|
||||
c.bench_function("request-from-path", |b| b.iter(||
|
||||
Request::from_http_get_path(black_box(INPUT))
|
||||
));
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
@ -147,7 +147,7 @@ impl Request {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// Seems to be a bit faster than non-memchr version
|
||||
/// Seems to be somewhat faster than non-memchr version
|
||||
fn parse_key_value_pairs_memchr<'a>(
|
||||
info_hashes: &mut Vec<String>,
|
||||
data: &mut HashMap<&'a str, String>,
|
||||
|
|
@ -222,6 +222,7 @@ impl Request {
|
|||
Ok(processed)
|
||||
}
|
||||
|
||||
/// Quite a bit faster than non-memchr version
|
||||
fn urldecode_memchr(value: &str) -> anyhow::Result<String> {
|
||||
let mut processed = String::with_capacity(value.len());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
{"group_id":"request-from-path","function_id":null,"value_str":null,"throughput":null,"full_id":"request-from-path","directory_name":"request-from-path","title":"request-from-path"}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3749.5055872769876,"upper_bound":3783.2703655553905},"point_estimate":3766.093336327674,"standard_error":8.62768938917972},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3687.4672404811445,"upper_bound":3708.700114153784},"point_estimate":3701.2006430041156,"standard_error":5.369535376928546},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":131.0000245768982,"upper_bound":152.13343559996954},"point_estimate":140.6084981812978,"standard_error":5.395688484573446},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3761.8699879889255,"upper_bound":3804.7796413016404},"point_estimate":3782.5656139118564,"standard_error":10.943849648456766},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":241.7583629895955,"upper_bound":304.36230650338575},"point_estimate":273.6771366722231,"standard_error":16.004559834945667}}
|
||||
1001
aquatic_http/target/criterion/request-from-path/latest/raw.csv
Normal file
1001
aquatic_http/target/criterion/request-from-path/latest/raw.csv
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[3023.921799212473,3318.088859655184,4102.534354169079,4396.701414611789]
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"group_id":"request-from-path","function_id":null,"value_str":null,"throughput":null,"full_id":"request-from-path","directory_name":"request-from-path","title":"request-from-path"}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":5824.69387789579,"upper_bound":5873.955231860259},"point_estimate":5848.060278693576,"standard_error":12.63942492388433},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":5758.391531674525,"upper_bound":5785.1963683827635},"point_estimate":5773.408873075845,"standard_error":7.037696580466141},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":157.64160863960012,"upper_bound":183.44129621404062},"point_estimate":170.6598530443819,"standard_error":6.5622373240938945},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":5832.402565777844,"upper_bound":5887.40667791996},"point_estimate":5858.714713470792,"standard_error":14.059707391986894},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":316.17183558077096,"upper_bound":500.59673643745384},"point_estimate":400.8496885755836,"standard_error":48.62413636310262}}
|
||||
1001
aquatic_http/target/criterion/request-from-path/no-memchr/raw.csv
Normal file
1001
aquatic_http/target/criterion/request-from-path/no-memchr/raw.csv
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[4974.032740058845,5318.589771364887,6237.408521514334,6581.965552820377]
|
||||
Loading…
Add table
Add a link
Reference in a new issue