Skip to content

Commit

Permalink
Adding some proofs that performance characteristics strange. EOM
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Visher committed Apr 30, 2012
1 parent 3f92adf commit 8848747
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ft4/beans/test/beans/test/core.clj
Expand Up @@ -32,3 +32,18 @@
(deftest it-should-allow-uac-field-lookup
(is (= "foo" (:name (->Address "foo" ["bar"] "bat" "bin" "biz"))))
(is (= "foo" (:name (test-address)))))

(defmacro xtime [expr]
`(let [start# (. System (nanoTime))
ret# ~expr]
(- (. System (nanoTime)) start#)))

(deftest it-should-perform-better-at-field-lookup
(let [address-record (->Address "foo" ["bar"] "bat" "bin" "biz")
address-map (test-address)]
(is (< (xtime (dotimes [n 10000000] (:name address-record))) (xtime (dotimes [n 10000000] (:name address-map)))))))

(deftest it-should-perform-better-at-field-lookup-but-it-does-not
(let [address-record (map->Address (test-address))
address-map (test-address)]
(is (not (< (xtime (:name address-record)) (xtime (:name address-map)))))))

0 comments on commit 8848747

Please sign in to comment.