mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
rename fn
This commit is contained in:
parent
c379b3956b
commit
8effac5da4
1 changed files with 28 additions and 30 deletions
|
@ -10,18 +10,18 @@ use json_rpc::{Id, Response};
|
|||
//---------------------------------------------------------------------------------------------------- Criterion
|
||||
criterion_group! {
|
||||
benches,
|
||||
from_str_u8,
|
||||
from_str_u64,
|
||||
from_str_string_5_len,
|
||||
from_str_string_10_len,
|
||||
from_str_string_100_len,
|
||||
from_str_string_500_len,
|
||||
to_string_pretty_u8,
|
||||
to_string_pretty_u64,
|
||||
to_string_pretty_string_5_len,
|
||||
to_string_pretty_string_10_len,
|
||||
to_string_pretty_string_100_len,
|
||||
to_string_pretty_string_500_len,
|
||||
response_from_str_u8,
|
||||
response_from_str_u64,
|
||||
response_from_str_string_5_len,
|
||||
response_from_str_string_10_len,
|
||||
response_from_str_string_100_len,
|
||||
response_from_str_string_500_len,
|
||||
response_to_string_pretty_u8,
|
||||
response_to_string_pretty_u64,
|
||||
response_to_string_pretty_string_5_len,
|
||||
response_to_string_pretty_string_10_len,
|
||||
response_to_string_pretty_string_100_len,
|
||||
response_to_string_pretty_string_500_len,
|
||||
}
|
||||
criterion_main!(benches);
|
||||
|
||||
|
@ -41,11 +41,9 @@ macro_rules! impl_from_str_benchmark {
|
|||
|
||||
c.bench_function(function_name!(), |b| {
|
||||
b.iter(|| {
|
||||
black_box(
|
||||
from_str::<Response<$request_type>>(
|
||||
black_box(request_string)
|
||||
)
|
||||
).unwrap();
|
||||
let _r = from_str::<Response<$request_type>>(
|
||||
black_box(request_string)
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -54,12 +52,12 @@ macro_rules! impl_from_str_benchmark {
|
|||
}
|
||||
|
||||
impl_from_str_benchmark! {
|
||||
from_str_u8 => u8 => r#"{"jsonrpc":"2.0","id":123,"result":0}"#,
|
||||
from_str_u64 => u64 => r#"{"jsonrpc":"2.0","id":123,"result":0}"#,
|
||||
from_str_string_5_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"hello"}"#,
|
||||
from_str_string_10_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"hellohello"}"#,
|
||||
from_str_string_100_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld"}"#,
|
||||
from_str_string_500_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld"}"#,
|
||||
response_from_str_u8 => u8 => r#"{"jsonrpc":"2.0","id":123,"result":0}"#,
|
||||
response_from_str_u64 => u64 => r#"{"jsonrpc":"2.0","id":123,"result":0}"#,
|
||||
response_from_str_string_5_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"hello"}"#,
|
||||
response_from_str_string_10_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"hellohello"}"#,
|
||||
response_from_str_string_100_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld"}"#,
|
||||
response_from_str_string_500_len => String => r#"{"jsonrpc":"2.0","id":123,"result":"helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld"}"#,
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Deserialization
|
||||
|
@ -78,7 +76,7 @@ macro_rules! impl_to_string_pretty_benchmark {
|
|||
|
||||
c.bench_function(function_name!(), |b| {
|
||||
b.iter(|| {
|
||||
black_box(to_string_pretty(black_box(&request))).unwrap();
|
||||
let _s = to_string_pretty(black_box(&request)).unwrap();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -87,10 +85,10 @@ macro_rules! impl_to_string_pretty_benchmark {
|
|||
}
|
||||
|
||||
impl_to_string_pretty_benchmark! {
|
||||
to_string_pretty_u8 => Response::<u8>::ok(Id::Null, 0),
|
||||
to_string_pretty_u64 => Response::<u64>::ok(Id::Null, 0),
|
||||
to_string_pretty_string_5_len => Response::ok(Id::Null, String::from("hello")),
|
||||
to_string_pretty_string_10_len => Response::ok(Id::Null, String::from("hellohello")),
|
||||
to_string_pretty_string_100_len => Response::ok(Id::Null, String::from("helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld")),
|
||||
to_string_pretty_string_500_len => Response::ok(Id::Null, String::from("helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld")),
|
||||
response_to_string_pretty_u8 => Response::<u8>::ok(Id::Null, 0),
|
||||
response_to_string_pretty_u64 => Response::<u64>::ok(Id::Null, 0),
|
||||
response_to_string_pretty_string_5_len => Response::ok(Id::Null, String::from("hello")),
|
||||
response_to_string_pretty_string_10_len => Response::ok(Id::Null, String::from("hellohello")),
|
||||
response_to_string_pretty_string_100_len => Response::ok(Id::Null, String::from("helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld")),
|
||||
response_to_string_pretty_string_500_len => Response::ok(Id::Null, String::from("helloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld")),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue