Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. fn test_fib<T: Fibonacci>(gen: &T) {
  2. let start_time = Local::now();
  3. let REPETITIONS = 50;
  4. let DEPTH = 35;
  5. for _ in 0..REPETITIONS {
  6. for number in 0..DEPTH {
  7. print_fib(gen, number);
  8. }
  9. }
  10.  
  11. let duration = Local::now().timestamp_millis() - start_time.timestamp_millis();
  12. println!(
  13. "{} * {} fibonacci numbers took {} milliseconds",
  14. REPETITIONS, DEPTH, duration
  15. );
  16. }
  17.  
  18. // vs
  19.  
  20.  
  21.  
  22. const REPETITIONS: usize = 50;
  23. const DEPTH: usize = 35;
  24. fn test_fib<T: Fibonacci>(gen: &T) {
  25. let start_time = Local::now();
  26. for _ in 0..REPETITIONS {
  27. for number in 0..DEPTH {
  28. print_fib(gen, number);
  29. }
  30. }
  31.  
  32. let duration = Local::now().timestamp_millis() - start_time.timestamp_millis();
  33. println!(
  34. "{} * {} fibonacci numbers took {} milliseconds",
  35. REPETITIONS, DEPTH, duration
  36. );
  37. }
Add Comment
Please, Sign In to add comment