-
Notifications
You must be signed in to change notification settings - Fork 0
/
pad_whitespace_leftalign.rs
50 lines (45 loc) · 1.36 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::*;
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("hej".pad(width, Alignment::Left, Symbol::Whitespace)))
});
}
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("bingbong".pad(width, Alignment::Left, Symbol::Whitespace)))
});
}
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("Undercity is a cool capital...".pad(
width,
Alignment::Left,
Symbol::Whitespace,
))
})
});
}
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("¤)(åäöåa this is a very long string... xd".pad(
width,
Alignment::Left,
Symbol::Whitespace,
))
})
});
}
criterion_group!(
pads,
pad_whitespace_10_leftalign,
pad_whitespace_100_leftalign,
pad_whitespace_1000_leftalign,
pad_whitespace_10000_leftalign,
);