2013/2/6 Christophe Grand <christo...@cgrand.net>

> Hi
>
> On Mon, Feb 4, 2013 at 2:29 PM, AtKaaZ <atk...@gmail.com> wrote:
>
>> => (class {:x "a" :y 3})
>>  clojure.lang.Persistent*Array*Map
>> => (def m {:x "a" :y 3})
>> #'runtime.q/m
>> => (class m)
>> clojure.lang.Persistent*Hash*Map
>>
>
> huh? that one I can't explain, I'll have to do some research.
>
> http://dev.clojure.org/jira/browse/CLJ-944
The second patch should adress this


> => (def m (let [] {:x "a" :y 3}))
> #'user/m
> => (class m)
> clojure.lang.PersistentArrayMap
>
>
>> => (time (dotimes [n 10000000] (hash m)))
>> "Elapsed time: 168.162927 msecs"
>> nil
>> => (time (dotimes [n 10000000] (hash m)))
>> "Elapsed time: 161.341094 msecs"
>> nil
>> => (time (dotimes [n 10000000] (hash m)))
>> "Elapsed time: 159.444025 msecs"
>> nil
>>
>>
> Since hash is cached and m doesn't change, more runs are just measuring
> the time to lookup the cache. There may be a sligt overhead due to m being
> a var.
>
> To properly isolate this you have to use locals:
> => (let [m (hash-map :x "a" :y 3)]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentHashMap
> "Elapsed time: 221.62 msecs"
> nil
> => (let [m (hash-map :x "a" :y 3)]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentHashMap
> "Elapsed time: 214.624 msecs"
> nil
> => (let [m (hash-map :x "a" :y 3)]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentHashMap
> "Elapsed time: 212.505 msecs"
> nil
> => (let [m {:x "a" :y 3}]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentArrayMap
> "Elapsed time: 232.872 msecs"
> nil
> => (let [m {:x "a" :y 3}]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentArrayMap
> "Elapsed time: 218.141 msecs"
> nil
> => (let [m {:x "a" :y 3}]
>      (println (class m))
>      (time (dotimes [n 10000000] (hash m))))
> clojure.lang.PersistentArrayMap
> "Elapsed time: 220.813 msecs"
> nil
>
> No significant change -- hopefully since 1e7-1 times out od 1z7 we are
> measuring the cost of looking up a cache.
>
> Christophe
>
> --
> On Clojure http://clj-me.cgrand.net/
> Clojure Programming http://clojurebook.com
> Training, Consulting & Contracting http://lambdanext.eu/
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to