Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. (defrecord Test [^long a ^long b ^long c])
  2.  
  3. (defn- test-1 [] (->Test (rand-int 1000) (rand-int 1000) (rand-int 1000)))
  4. (defn- redx-1 [S ^Test {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  5. (defn- redx-1-2 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  6.  
  7. (defn- test-2 [] {:a (rand-int 1000) :b (rand-int 1000) :c (rand-int 1000)})
  8. (defn- redx-2 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  9.  
  10. (defn- test-3 [] (hash-map :a (rand-int 1000) :b (rand-int 1000) :c (rand-int 1000)))
  11. (defn- redx-3 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  12.  
  13. (defn- test-4 [] (vector (rand-int 1000) (rand-int 1000) (rand-int 1000)))
  14. (defn- redx-4 [S [a b c]] (+ S (* a b) c (* a c)))
  15.  
  16. (defn- test-5 [] [(rand-int 1000) (rand-int 1000) (rand-int 1000)])
  17. (defn- redx-5 [S [a b c]] (+ S (* a b) c (* a c)))
  18.  
  19. (def ^:private ^:const N 1e+7)
  20.  
  21. (defrecord Test-2 [a b c])
  22.  
  23. (defn- test-6 [] (->Test-2 (rand-int 1000) (rand-int 1000) (rand-int 1000)))
  24. (defn- redx-6 [S ^Test-2 {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  25. (defn- redx-6-1 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
  26.  
  27. (doseq [[r t] (list [redx-1 test-1]
  28. [redx-2 test-2]
  29. [redx-3 test-3]
  30. [redx-4 test-4]
  31. [redx-5 test-5]
  32. [redx-6 test-6]
  33. [redx-6-1 test-6])]
  34. (time (reduce r 0 (repeatedly N t))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement