Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,54 @@
|
||||
use super::*;
|
||||
use std::{collections::BTreeMap, hint::black_box, time::Instant};
|
||||
|
||||
#[test]
|
||||
#[ignore = "explicit release performance probe"]
|
||||
fn multipart_field_cost() {
|
||||
let directory = Directory::new();
|
||||
Runtime::new(TaskLimits::default())
|
||||
.unwrap()
|
||||
.run(async |scope| {
|
||||
println!("\ncase,sample,iterations,elapsed_ns,checksum");
|
||||
for count in [1, 16, 64] {
|
||||
let mut source = String::new();
|
||||
for index in 0..count {
|
||||
source.push_str(&format!(
|
||||
"--boundary\r\nContent-Disposition: form-data; name=field{index}\r\n\r\n{}\r\n",
|
||||
"a".repeat(64)
|
||||
));
|
||||
}
|
||||
source.push_str("--boundary--\r\n");
|
||||
let bytes = Bytes::from(source);
|
||||
let limits = Limits {
|
||||
fields: count,
|
||||
parts: count,
|
||||
..Limits::default()
|
||||
};
|
||||
for sample in 0..15 {
|
||||
let started = Instant::now();
|
||||
let mut checksum = 0;
|
||||
for _ in 0..1000 {
|
||||
let multipart = upload::decode(
|
||||
http_body_util::Full::new(black_box(bytes.clone())),
|
||||
"multipart/form-data; boundary=boundary",
|
||||
&directory.0,
|
||||
&limits,
|
||||
scope,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let fields = multipart
|
||||
.finish()
|
||||
.unwrap()
|
||||
.decode::<BTreeMap<String, String>>(dever_runtime::wire::decode)
|
||||
.unwrap();
|
||||
checksum += black_box(fields.len());
|
||||
}
|
||||
let elapsed = started.elapsed().as_nanos();
|
||||
assert_eq!(checksum, count * 1000);
|
||||
println!("multipart_{count},{sample},1000,{elapsed},{checksum}");
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
Reference in new issue
Block a user