Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. (in-package :rtg-math)
  2.  
  3. (defun rand-m4 ()
  4. (m4:make (- (random 20f0) 10f0)
  5. (- (random 20f0) 10f0)
  6. (- (random 20f0) 10f0)
  7. (- (random 20f0) 10f0)
  8. (- (random 20f0) 10f0)
  9. (- (random 20f0) 10f0)
  10. (- (random 20f0) 10f0)
  11. (- (random 20f0) 10f0)
  12. (- (random 20f0) 10f0)
  13. (- (random 20f0) 10f0)
  14. (- (random 20f0) 10f0)
  15. (- (random 20f0) 10f0)
  16. (- (random 20f0) 10f0)
  17. (- (random 20f0) 10f0)
  18. (- (random 20f0) 10f0)
  19. (- (random 20f0) 10f0)))
  20.  
  21. (defun make-circle-of-n (n)
  22. (let ((r (loop :for i :below n :collect (rand-m4))))
  23. (setf (cdr (last r)) r)
  24. r))
  25.  
  26.  
  27. (defun test ()
  28. (let ((data (make-circle-of-n 1000))
  29. (sample (rand-m4))
  30. (dummy nil))
  31. (time
  32. (loop :for i :below 1000000 :for d :in data :do
  33. (setf dummy (m4:= sample d))))
  34. (time
  35. (loop :for i :below 1000000 :for d :in data :do
  36. (setf dummy (equalp sample d))))
  37. (print dummy)))
  38.  
  39.  
  40. ;; RTG-MATH> (test)
  41.  
  42. ;; Evaluation took:
  43. ;; 0.012 seconds of real time
  44. ;; 0.012000 seconds of total run time (0.012000 user, 0.000000 system)
  45. ;; 100.00% CPU
  46. ;; 36,713,970 processor cycles
  47. ;; 0 bytes consed
  48.  
  49. ;; Evaluation took:
  50. ;; 0.039 seconds of real time
  51. ;; 0.040000 seconds of total run time (0.040000 user, 0.000000 system)
  52. ;; 102.56% CPU
  53. ;; 118,637,629 processor cycles
  54. ;; 5,520 bytes consed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement