-
Notifications
You must be signed in to change notification settings - Fork 0
/
pad_whitespace_leftalign.rs
50 lines (45 loc) · 1.38 KB
/
pad_whitespace_leftalign.rs
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
use criterion::{black_box, criterion_group, Criterion};
use padder::whitespace;
use padder::Alignment;
pub fn pad_whitespace_10_leftalign(c: &mut Criterion) {
let width: usize = 10;
c.bench_function("pad ws 10 la", |b| {
b.iter(|| black_box(whitespace("hej", width, Alignment::Left).unwrap()))
});
}
pub fn pad_whitespace_100_leftalign(c: &mut Criterion) {
let width: usize = 100;
c.bench_function("pad ws 100 la", |b| {
b.iter(|| black_box(whitespace("bingbong", width, Alignment::Left).unwrap()))
});
}
pub fn pad_whitespace_1000_leftalign(c: &mut Criterion) {
let width: usize = 1000;
c.bench_function("pad ws 1000 la", |b| {
b.iter(|| {
black_box(whitespace("Undercity is a cool capital...", width, Alignment::Left).unwrap())
})
});
}
pub fn pad_whitespace_10000_leftalign(c: &mut Criterion) {
let width: usize = 10000;
c.bench_function("pad ws 10000 la", |b| {
b.iter(|| {
black_box(
whitespace(
"¤)(åäöåa this is a very long string... xd",
width,
Alignment::Left,
)
.unwrap(),
)
})
});
}
criterion_group!(
pads,
pad_whitespace_10_leftalign,
pad_whitespace_100_leftalign,
pad_whitespace_1000_leftalign,
pad_whitespace_10000_leftalign,
);