aquatic_http: request from path: remove from map to avoid some clones

change: [-3.8362% -3.2346% -2.5437%] (p = 0.00 < 0.01)
Performance has improved.
This commit is contained in:
Joakim Frostegård 2020-07-19 13:24:48 +02:00
parent ca8d278a03
commit b17c9999f0
5 changed files with 1010 additions and 1010 deletions

View file

@ -60,7 +60,7 @@ impl Request {
)?;
if location == "/announce" {
let numwant = if let Some(s) = data.get("numwant"){
let numwant = if let Some(s) = data.remove("numwant"){
let numwant = s.parse::<usize>()
.map_err(|err|
anyhow::anyhow!("parse 'numwant': {}", err)
@ -70,12 +70,12 @@ impl Request {
} else {
None
};
let key = if let Some(s) = data.get("key"){
let key = if let Some(s) = data.remove("key"){
if s.len() > 100 {
return Err(anyhow::anyhow!("'key' is too long"))
}
Some(s.clone())
Some(s)
} else {
None
};
@ -89,18 +89,18 @@ impl Request {
.with_context(|| "no peer_id")
.and_then(|s| deserialize_20_bytes(s))
.map(PeerId)?,
port: data.get("port")
port: data.remove("port")
.with_context(|| "no port")
.and_then(|s| s.parse()
.map_err(|err| anyhow::anyhow!("parse 'port': {}", err)))?,
bytes_left: data.get("left")
bytes_left: data.remove("left")
.with_context(|| "no left")
.and_then(|s| s.parse()
.map_err(|err| anyhow::anyhow!("parse 'left': {}", err)))?,
event: data.get("event")
event: data.remove("event")
.and_then(|s| s.parse().ok())
.unwrap_or_default(),
compact: data.get("compact")
compact: data.remove("compact")
.map(|s| s == "1")
.unwrap_or(true),
numwant,

View file

@ -1 +1 @@
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3747.1235505684463,"upper_bound":3775.4792697171138},"point_estimate":3760.8178721015074,"standard_error":7.2434996906468925},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3708.5693599361093,"upper_bound":3724.744478441148},"point_estimate":3719.449350467544,"standard_error":4.187042586445918},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":95.91763682926207,"upper_bound":117.59276597163861},"point_estimate":107.37477461147462,"standard_error":5.538505171592265},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3779.8768529936756,"upper_bound":3822.820449054469},"point_estimate":3800.581120971367,"standard_error":10.932410123580997},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":195.1820317005926,"upper_bound":260.7777004749326},"point_estimate":228.48228831326324,"standard_error":16.87170456516416}}
{"mean":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3620.223185445427,"upper_bound":3660.1054580320942},"point_estimate":3639.1705234625256,"standard_error":10.23030590161961},"median":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3573.248635351063,"upper_bound":3590.1493227124265},"point_estimate":3581.371033648157,"standard_error":4.667798258726669},"median_abs_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":97.9344093806613,"upper_bound":119.75600340036665},"point_estimate":107.24540589334634,"standard_error":5.4808042142175495},"slope":{"confidence_interval":{"confidence_level":0.95,"lower_bound":3619.5284724763083,"upper_bound":3656.7793470824513},"point_estimate":3637.3029331473836,"standard_error":9.48013840981128},"std_dev":{"confidence_interval":{"confidence_level":0.95,"lower_bound":247.96259922399872,"upper_bound":395.99450743999654},"point_estimate":322.5988272216282,"standard_error":37.832790227752945}}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
[3224.065097175909,3437.935635898498,4008.257072492067,4222.127611214655]
[3073.4575890843375,3293.348255296047,3879.7233651939387,4099.614031405648]