1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#![feature(test)]
#[cfg(test)]
mod benches {
extern crate serenity;
extern crate test;
use self::serenity::framework::standard::Args;
use self::test::Bencher;
#[bench]
fn single_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2", &[",".to_string()]);
args.single::<String>().unwrap();
})
}
#[bench]
fn single_with_one_delimiter_and_long_string(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25", &[",".to_string()]);
args.single::<String>().unwrap();
})
}
#[bench]
fn single_with_three_delimiters(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2 @3@4 5,", &[",".to_string(), " ".to_string(), "@".to_string()]);
args.single::<String>().unwrap();
})
}
#[bench]
fn single_with_three_delimiters_and_long_string(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2 @3@4 5,1,2 @3@4 5,1,2 @3@4 5,1,2 @3@4 5,1,2 @3@4 5,1,2 @3@4 5,", &[",".to_string(), " ".to_string(), "@".to_string()]);
args.single::<String>().unwrap();
})
}
#[bench]
fn single_quoted_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new(r#""1","2""#, &[",".to_string()]);
args.single_quoted::<String>().unwrap();
})
}
#[bench]
fn len_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2,3,4,5,6,7,8,9,10,11,12,13,14", &[",".to_string()]);
args.len();
})
}
#[bench]
fn double_len_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2,3,4,5,6,7,8,9,10,11,12,13,14", &[",".to_string()]);
args.len();
args.len();
})
}
#[bench]
fn double_len_quoted_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new(r#""a" "a" "a" "a" "a" "a" "a" "a" "a" "a""#, &[" ".to_string()]);
args.len_quoted();
args.len_quoted();
})
}
#[bench]
fn len_with_three_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new("1,2,3,4@5,6,7@8,9,10@11,12#13,14", &[",".to_string(), "@".to_string(), "#".to_string()]);
args.len();
})
}
#[bench]
fn len_quoted_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new(r#""1","2","3","4","5","6","7","8","9","10""#, &[",".to_string()]);
args.len();
})
}
#[bench]
fn len_quoted_with_three_delimiter(b: &mut Bencher) {
b.iter(|| {
let mut args = Args::new(r#""1"-"2"<"3","4","5","6","7"<"8","9"<"10""#, &[",".to_string(), "-".to_string(), "<".to_string()]);
args.len();
})
}
#[bench]
fn multiple_with_one_delimiter(b: &mut Bencher) {
b.iter(|| {
let args = Args::new("1,2,3,4,5,6,7,8,9,10", &[",".to_string()]);
args.multiple::<String>().unwrap();
})
}
#[bench]
fn multiple_with_three_delimiters(b: &mut Bencher) {
b.iter(|| {
let args = Args::new("1-2<3,4,5,6,7<8,9,10", &[",".to_string(), "-".to_string(), "<".to_string()]);
args.multiple::<String>().unwrap();
})
}
}
|