-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlib.rs
52 lines (42 loc) · 1.07 KB
/
lib.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
51
52
#![feature(test)]
extern crate test;
#[macro_use]
extern crate throw;
use std::result::Result as StdResult;
use test::Bencher;
use throw::Result;
#[inline(never)]
fn gives_throw_ok() -> Result<&'static str, &'static str> {
test::black_box(Ok("ok"))
}
#[inline(never)]
fn gives_ok() -> StdResult<&'static str, &'static str> {
test::black_box(Ok("ok"))
}
#[inline(never)]
fn throws_up_ok() -> Result<&'static str, &'static str> {
let ok_msg = test::black_box(up!(gives_throw_ok()));
Ok(ok_msg)
}
#[inline(never)]
fn throws_throw_ok() -> Result<&'static str, &'static str> {
let ok_msg = test::black_box(throw!(gives_ok()));
Ok(ok_msg)
}
#[inline(never)]
fn throws_try_ok() -> StdResult<&'static str, &'static str> {
let ok_msg = test::black_box(try!(gives_ok()));
Ok(ok_msg)
}
#[bench]
fn bench_throw_ok_return(bench: &mut Bencher) {
bench.iter(|| throws_throw_ok())
}
#[bench]
fn bench_up_ok_return(bench: &mut Bencher) {
bench.iter(|| throws_up_ok())
}
#[bench]
fn bench_try_ok_return(bench: &mut Bencher) {
bench.iter(|| throws_try_ok())
}