Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. extern crate test;
  2.  
  3. use test::Bencher;
  4.  
  5. static LIMIT : u64 = 10_000_000;
  6.  
  7. fn int_sum() -> u64 {
  8. let mut sum = 0;
  9. let mut counter = 0;
  10. while counter < LIMIT {
  11. sum += counter;
  12. counter+=1;
  13. }
  14. sum
  15. }
  16.  
  17. #[bench]
  18. fn int_sum_bencher(b: &mut Bencher) {
  19. b.iter(|| {
  20. int_sum()
  21. })
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement