From 88487470b07eb0b59c40c75782e90eb9bf8e07f3 Mon Sep 17 00:00:00 2001 From: Tim Visher Date: Mon, 30 Apr 2012 10:48:09 -0400 Subject: [PATCH] Adding some proofs that performance characteristics strange. EOM --- ft4/beans/test/beans/test/core.clj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ft4/beans/test/beans/test/core.clj b/ft4/beans/test/beans/test/core.clj index 55aea1d..d667d37 100644 --- a/ft4/beans/test/beans/test/core.clj +++ b/ft4/beans/test/beans/test/core.clj @@ -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))))))) \ No newline at end of file