SHARE
TWEET

Untitled

a guest May 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![feature(test)]
  2.  
  3.  
  4. extern crate test;
  5.  
  6. pub fn add_two(a: i32) -> i32 {
  7.     a + 2
  8. }
  9.  
  10. #[cfg(test)]
  11. mod tests {
  12.     use super::*;
  13.     use test::Bencher;
  14.  
  15.     #[test]
  16.     fn it_works() {
  17.         assert_eq!(4, add_two(2));
  18.     }
  19.  
  20.     #[bench]
  21.     fn bench_add_two(b: &mut Bencher) {
  22.         b.iter(|| add_two(2));
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top