summaryrefslogtreecommitdiffstats
path: root/third_party/rust/mime/benches/parse.rs
blob: 7d47781a0d30339ca40858a33e8682d6059ce967 (plain)
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
#![feature(test)]

extern crate mime;
extern crate test;

use mime::Mime;
use test::Bencher;


#[bench]
fn bench_from_str(b: &mut Bencher) {
    let s = "text/plain";
    b.bytes = s.as_bytes().len() as u64;
    b.iter(|| s.parse::<Mime>())
}

#[bench]
fn bench_from_str_charset_utf8(b: &mut Bencher) {
    let s = "text/plain; charset=utf-8";
    b.bytes = s.as_bytes().len() as u64;
    b.iter(|| s.parse::<Mime>())
}

#[bench]
fn bench_from_str_extended(b: &mut Bencher) {
    let s = "text/plain; charset=utf-8; foo=bar";
    b.bytes = s.as_bytes().len() as u64;
    b.iter(|| s.parse::<Mime>())
}