Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defrecord Test [^long a ^long b ^long c])
- (defn- test-1 [] (->Test (rand-int 1000) (rand-int 1000) (rand-int 1000)))
- (defn- redx-1 [S ^Test {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (defn- redx-1-2 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (defn- test-2 [] {:a (rand-int 1000) :b (rand-int 1000) :c (rand-int 1000)})
- (defn- redx-2 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (defn- test-3 [] (hash-map :a (rand-int 1000) :b (rand-int 1000) :c (rand-int 1000)))
- (defn- redx-3 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (defn- test-4 [] (vector (rand-int 1000) (rand-int 1000) (rand-int 1000)))
- (defn- redx-4 [S [a b c]] (+ S (* a b) c (* a c)))
- (defn- test-5 [] [(rand-int 1000) (rand-int 1000) (rand-int 1000)])
- (defn- redx-5 [S [a b c]] (+ S (* a b) c (* a c)))
- (def ^:private ^:const N 1e+7)
- (defrecord Test-2 [a b c])
- (defn- test-6 [] (->Test-2 (rand-int 1000) (rand-int 1000) (rand-int 1000)))
- (defn- redx-6 [S ^Test-2 {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (defn- redx-6-1 [S {a :a b :b c :c}] (+ S (* a b) c (* a c)))
- (doseq [[r t] (list [redx-1 test-1]
- [redx-2 test-2]
- [redx-3 test-3]
- [redx-4 test-4]
- [redx-5 test-5]
- [redx-6 test-6]
- [redx-6-1 test-6])]
- (time (reduce r 0 (repeatedly N t))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement