mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
Run rustfmt, clean up aquatic_http_protocol/Cargo.toml
This commit is contained in:
parent
0cc312a78d
commit
d0e716f80b
65 changed files with 1754 additions and 2590 deletions
|
|
@ -1,27 +1,25 @@
|
|||
use std::time::Duration;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use std::time::Duration;
|
||||
|
||||
use aquatic_ws_protocol::*;
|
||||
|
||||
|
||||
pub fn bench(c: &mut Criterion) {
|
||||
let info_hash = InfoHash([
|
||||
b'a', b'b', b'c', b'd', b'e',
|
||||
b'?', b'\n', b'1', b'2', b'3',
|
||||
0, 1, 2, 3, 4,
|
||||
0, 1, 2, 3, 4,
|
||||
b'a', b'b', b'c', b'd', b'e', b'?', b'\n', b'1', b'2', b'3', 0, 1, 2, 3, 4, 0, 1, 2, 3, 4,
|
||||
]);
|
||||
let peer_id = PeerId(info_hash.0);
|
||||
let offers: Vec<AnnounceRequestOffer> = (0..10).map(|i| {
|
||||
let mut offer_id = OfferId(info_hash.0);
|
||||
|
||||
offer_id.0[i] = i as u8;
|
||||
let offers: Vec<AnnounceRequestOffer> = (0..10)
|
||||
.map(|i| {
|
||||
let mut offer_id = OfferId(info_hash.0);
|
||||
|
||||
AnnounceRequestOffer {
|
||||
offer: JsonValue(::serde_json::json!({ "sdp": "abcdef" })),
|
||||
offer_id,
|
||||
}
|
||||
}).collect();
|
||||
offer_id.0[i] = i as u8;
|
||||
|
||||
AnnounceRequestOffer {
|
||||
offer: JsonValue(::serde_json::json!({ "sdp": "abcdef" })),
|
||||
offer_id,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let offers_len = offers.len();
|
||||
|
||||
let request = InMessage::AnnounceRequest(AnnounceRequest {
|
||||
|
|
@ -34,17 +32,17 @@ pub fn bench(c: &mut Criterion) {
|
|||
numwant: Some(offers_len),
|
||||
answer: Some(JsonValue(::serde_json::json!({ "sdp": "abcdef" }))),
|
||||
to_peer_id: Some(peer_id),
|
||||
offer_id: Some(OfferId(info_hash.0))
|
||||
offer_id: Some(OfferId(info_hash.0)),
|
||||
});
|
||||
|
||||
let ws_message = request.to_ws_message();
|
||||
|
||||
c.bench_function("deserialize-announce-request", |b| b.iter(||
|
||||
InMessage::from_ws_message(black_box(ws_message.clone()))
|
||||
));
|
||||
c.bench_function("deserialize-announce-request", |b| {
|
||||
b.iter(|| InMessage::from_ws_message(black_box(ws_message.clone())))
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!{
|
||||
criterion_group! {
|
||||
name = benches;
|
||||
config = Criterion::default()
|
||||
.sample_size(1000)
|
||||
|
|
@ -52,4 +50,4 @@ criterion_group!{
|
|||
.significance_level(0.01);
|
||||
targets = bench
|
||||
}
|
||||
criterion_main!(benches);
|
||||
criterion_main!(benches);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue