• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![cfg(feature = "kv_unstable")]
2 #![feature(test)]
3 
4 extern crate log;
5 extern crate test;
6 
7 use log::kv::Value;
8 
9 #[bench]
u8_to_value(b: &mut test::Bencher)10 fn u8_to_value(b: &mut test::Bencher) {
11     b.iter(|| Value::from(1u8))
12 }
13 
14 #[bench]
u8_to_value_debug(b: &mut test::Bencher)15 fn u8_to_value_debug(b: &mut test::Bencher) {
16     b.iter(|| Value::from_debug(&1u8))
17 }
18 
19 #[bench]
str_to_value_debug(b: &mut test::Bencher)20 fn str_to_value_debug(b: &mut test::Bencher) {
21     b.iter(|| Value::from_debug(&"a string"))
22 }
23 
24 #[bench]
custom_to_value_debug(b: &mut test::Bencher)25 fn custom_to_value_debug(b: &mut test::Bencher) {
26     #[derive(Debug)]
27     struct A;
28 
29     b.iter(|| Value::from_debug(&A))
30 }
31