Last active
January 24, 2019 22:22
-
-
Save yamafaktory/38c2f54b0b94faebfd790783150c3d1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
extern crate test; | |
pub fn minus_one(number: i32) -> i32 { | |
number - 1 | |
} | |
#[cfg(test)] | |
mod tests { | |
use super::*; | |
use test::Bencher; | |
#[test] | |
fn test_minus_one() { | |
assert_eq!(minus_one(1), 0); | |
} | |
#[bench] | |
fn bench_minus_one(b: &mut Bencher) { | |
b.iter(|| minus_one(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment