Re: Performance issue with hashing records

2013-02-06 Thread Christophe Grand
Hi,

On Mon, Feb 4, 2013 at 12:13 PM, Paul Stadig p...@stadig.name wrote:

 On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote:

 In these examples, the map/record is freshly created each time through
 the loop, so caching should not be a factor.


 Good point. So maybe it's not the caching :).


No Paul, you were right: it's the caching. The map is seen as constant and
its creation is hoisted outside of the loop so hash is called 1e7 times on
the same map object. While a new record is created at each iteration.

If you rewrite  (time (dotimes [n 1000] (hash (A. a 3 as  (time
(dotimes [n 1000] (hash #user.A[a 3]))) you get a single record
instance -- but still no caching on records.

In my patch to fix the hashing caching (or lack of) I didn't cover records
because it's more involved: it requires changes to the compiler because we
need to add new fields to the record to hold the cached value -- fields
that must not be part of the constructor.

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.




Re: Performance issue with hashing records

2013-02-06 Thread Christophe Grand
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.

= (def m (let [] {:x a :y 3}))
#'user/m
= (class m)
clojure.lang.PersistentArrayMap


 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 168.162927 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 161.341094 msecs
 nil
 = (time (dotimes [n 1000] (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 1000] (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 1000] (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 1000] (hash m
clojure.lang.PersistentHashMap
Elapsed time: 212.505 msecs
nil
= (let [m {:x a :y 3}]
 (println (class m))
 (time (dotimes [n 1000] (hash m
clojure.lang.PersistentArrayMap
Elapsed time: 232.872 msecs
nil
= (let [m {:x a :y 3}]
 (println (class m))
 (time (dotimes [n 1000] (hash m
clojure.lang.PersistentArrayMap
Elapsed time: 218.141 msecs
nil
= (let [m {:x a :y 3}]
 (println (class m))
 (time (dotimes [n 1000] (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.




Re: Performance issue with hashing records

2013-02-06 Thread AtKaaZ
Hi. Thank you.


On Wed, Feb 6, 2013 at 10:50 AM, Christophe Grand christo...@cgrand.netwrote:

 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.

 = (def m (let [] {:x a :y 3}))
 #'user/m
 = (class m)
 clojure.lang.PersistentArrayMap


 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 168.162927 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 161.341094 msecs
 nil
 = (time (dotimes [n 1000] (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 1000] (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 1000] (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 1000] (hash m
 clojure.lang.PersistentHashMap
 Elapsed time: 212.505 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (hash m
 clojure.lang.PersistentArrayMap
 Elapsed time: 232.872 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (hash m
 clojure.lang.PersistentArrayMap
 Elapsed time: 218.141 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (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.






-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-06 Thread Bronsa
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 1000] (hash m)))
 Elapsed time: 168.162927 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 161.341094 msecs
 nil
 = (time (dotimes [n 1000] (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 1000] (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 1000] (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 1000] (hash m
 clojure.lang.PersistentHashMap
 Elapsed time: 212.505 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (hash m
 clojure.lang.PersistentArrayMap
 Elapsed time: 232.872 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (hash m
 clojure.lang.PersistentArrayMap
 Elapsed time: 218.141 msecs
 nil
 = (let [m {:x a :y 3}]
  (println (class m))
  (time (dotimes [n 1000] (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.




Re: Performance issue with hashing records

2013-02-04 Thread Paul Stadig
On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote:

 In these examples, the map/record is freshly created each time through the 
 loop, so caching should not be a factor.  


Good point. So maybe it's not the caching :).

Another factor is that literal hashmaps are actually PersistentArrayMaps. 
If you use PersistentHashMaps instead of PersistentArrayMaps you get 
similar performance:

Clojure 1.5.0-RC4
user= (class {:x a :y 3})
clojure.lang.PersistentArrayMap
user= (time (dotimes [n 1000] (hash (hash-map :x a :y 3
Elapsed time: 3315.031872 msecs
nil


Paul

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-04 Thread AtKaaZ
On Mon, Feb 4, 2013 at 12:13 PM, Paul Stadig p...@stadig.name wrote:

 On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote:

 In these examples, the map/record is freshly created each time through
 the loop, so caching should not be a factor.


 Good point. So maybe it's not the caching :).

 Another factor is that literal hashmaps are actually PersistentArrayMaps.
 If you use PersistentHashMaps instead of PersistentArrayMaps you get
 similar performance:

 Clojure 1.5.0-RC4
 user= (class {:x a :y 3})
 clojure.lang.PersistentArrayMap

well that explains why there's more time in this sample:
= (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
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 168.162927 msecs
nil
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 161.341094 msecs
nil
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 159.444025 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 54.29475 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 68.322372 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 57.707132 msecs
nil


 user= (time (dotimes [n 1000] (hash (hash-map :x a :y 3
 Elapsed time: 3315.031872 msecs
 nil

 = (time (dotimes [n 1000] (hash (hash-map :x a :y 3
Elapsed time: 8495.188813 msecs
= (def hm (hash-map :x a :y 3))
#'runtime.q/hm
= (time (dotimes [n 1000] (hash hm)))
Elapsed time: 155.623505 msecs
nil
= (time (dotimes [n 1000] (hash hm)))
Elapsed time: 160.494044 msecs
nil



 Paul

 --
 --
 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.






-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-03 Thread Mark Engelberg
I don't think this particular example relates.

Memoize produces a function, so the time spent is really about hashing
functions which presumably hashes on the address of the function (or
something similar) and never touches the underlying record.
In the later example, you are mostly timing the cost of repeatedly
memoizing, which creates a lot of anonymous functions, and would be
expected to be more time-consuming.

The other examples you posted are interesting, though.

On Sat, Feb 2, 2013 at 11:31 PM, AtKaaZ atk...@gmail.com wrote:

 ok i like this variant:
 = (def r (memoize (A. a 3)))

 #'runtime.q_test/r
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 342.363961 msecs

 nil
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 361.66747 msecs
 nil

 = (time (dotimes [n 1000] (hash (memoize (A. a 3)
 Elapsed time: 1812.016478 msecs
 nil
 = (time (dotimes [n 1000] (hash (memoize (A. a 3)
 Elapsed time: 1847.244062 msecs
 nil




 On Sun, Feb 3, 2013 at 8:29 AM, AtKaaZ atk...@gmail.com wrote:

 = (def m {:x a :y 3})
 #'runtime.q_test/m
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 154.650091 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 164.724641 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 150.194984 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 57.981602 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.803223 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 67.395947 msecs
 nil


 = (def r (A. a 3))
 #'runtime.q_test/r
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4906.641334 msecs
 nil
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4959.124395 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4842.496589 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4856.855515 msecs
 nil




 On Sun, Feb 3, 2013 at 8:26 AM, AtKaaZ atk...@gmail.com wrote:

 he's in RC4
 = *clojure-version*
 {:major 1, :minor 5, :incremental 0, :qualifier RC4}


 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.037502 msecs


 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5307.93947 msecs


 On Sun, Feb 3, 2013 at 8:22 AM, Leonardo Borges 
 leonardoborges...@gmail.com wrote:

 Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
 got results similar to yours.

 In Clojure 1.4, I get this:

 user (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 5993.331 msecs
 nil
 user  (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 3144.368 msecs

 No clue as to the reason though - but it seems something might have
 changed from 1.4 to 1.5?


 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg 
 mark.engelb...@gmail.com wrote:
  I just went through the process of converting my map-based program
 over to
  records, hoping it would improve speed.  Much to my dismay, it
 actually
  slowed my program down substantially.  With some profiling, I
 discovered
  that one possible explanation is that (at least in RC4) hashing of
 records
  is about 60x slower than their map-based counterpart.
 
  (defrecord A [x y])
  = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 90.631072 msecs
  = (time (dotimes [n 1000] (hash (A. a 3
  Elapsed time: 5549.788311 msecs
 
  Any thoughts about why this is the case?
 
  --
  --
  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.





 --
 Please correct me if I'm wrong 

Re: Performance issue with hashing records

2013-02-03 Thread AtKaaZ
ah I see, you're right , which made me think why would memoize allow
non-func but then I realized this:
= *((memoize {:key 1}) :key)*
1
=* ((memoize {:key 1}) :ke)*
nil




this is what I thought I was doing:
= *(def g (A. a 3))*
#'runtime.q_test/g
= *(defn f [] g)*
#'runtime.q_test/f
= *(def r (memoize f))*
#'runtime.q_test/r
=* (time (dotimes [n 1000] (hash (r*
Elapsed time: 5595.312905 msecs
nil
=* (time (dotimes [n 1000] (hash (r*
Elapsed time: 5644.041368 msecs
nil
= *(r)*
#runtime.q_test.A{:x a, :y 3}
= *r*
#core$memoize$fn__5074 clojure.core$memoize$fn__5074@4482a7fa
= *r*
#core$memoize$fn__5074 clojure.core$memoize$fn__5074@4482a7fa


= *(def r (memoize #(A. a 3)))*
#'runtime.q_test/r
= *(time (dotimes [n 1000] (hash (r*
Elapsed time: 5645.559622 msecs
nil
= *(time (dotimes [n 1000] (hash (r*
Elapsed time: 5595.968715 msecs
nil

(wonder how do some people paste colored clojure code, I'm guessing they
paste html but what do they use for to generate it? doesn't look like they
use refheap for example)


On Sun, Feb 3, 2013 at 9:13 AM, Mark Engelberg mark.engelb...@gmail.comwrote:

 I don't think this particular example relates.

 Memoize produces a function, so the time spent is really about hashing
 functions which presumably hashes on the address of the function (or
 something similar) and never touches the underlying record.
 In the later example, you are mostly timing the cost of repeatedly
 memoizing, which creates a lot of anonymous functions, and would be
 expected to be more time-consuming.

 The other examples you posted are interesting, though.


 On Sat, Feb 2, 2013 at 11:31 PM, AtKaaZ atk...@gmail.com wrote:

 ok i like this variant:
 = (def r (memoize (A. a 3)))

 #'runtime.q_test/r
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 342.363961 msecs

 nil
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 361.66747 msecs
 nil

 = (time (dotimes [n 1000] (hash (memoize (A. a 3)
 Elapsed time: 1812.016478 msecs
 nil
 = (time (dotimes [n 1000] (hash (memoize (A. a 3)
 Elapsed time: 1847.244062 msecs
 nil




 On Sun, Feb 3, 2013 at 8:29 AM, AtKaaZ atk...@gmail.com wrote:

 = (def m {:x a :y 3})
 #'runtime.q_test/m
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 154.650091 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 164.724641 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 150.194984 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 57.981602 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.803223 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 67.395947 msecs
 nil


 = (def r (A. a 3))
 #'runtime.q_test/r
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4906.641334 msecs
 nil
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4959.124395 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4842.496589 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4856.855515 msecs
 nil




 On Sun, Feb 3, 2013 at 8:26 AM, AtKaaZ atk...@gmail.com wrote:

 he's in RC4
 = *clojure-version*
 {:major 1, :minor 5, :incremental 0, :qualifier RC4}


 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.037502 msecs


 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5307.93947 msecs


 On Sun, Feb 3, 2013 at 8:22 AM, Leonardo Borges 
 leonardoborges...@gmail.com wrote:

 Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
 got results similar to yours.

 In Clojure 1.4, I get this:

 user (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 5993.331 msecs
 nil
 user  (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 3144.368 msecs

 No clue as to the reason though - but it seems something might have
 changed from 1.4 to 1.5?


 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg 
 mark.engelb...@gmail.com wrote:
  I just went through the process of converting my map-based program
 over to
  records, hoping it would improve speed.  Much to my dismay, it
 actually
  slowed my program down substantially.  With some profiling, I
 discovered
  that one possible explanation is that (at least in RC4) hashing of
 records
  is about 60x slower than their map-based counterpart.
 
  (defrecord A [x y])
  = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 90.631072 msecs
  = (time (dotimes [n 1000] (hash (A. a 3
  Elapsed time: 5549.788311 msecs
 
  Any thoughts about why this is the case?
 
  --
  --
  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
  

Re: Performance issue with hashing records

2013-02-03 Thread Paul Stadig
On Sunday, February 3, 2013 1:07:41 AM UTC-5, puzzler wrote:

 I just went through the process of converting my map-based program over to 
 records, hoping it would improve speed.  Much to my dismay, it actually 
 slowed my program down substantially.  With some profiling, I discovered 
 that one possible explanation is that (at least in RC4) hashing of records 
 is about 60x slower than their map-based counterpart.

 (defrecord A [x y])
 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 90.631072 msecs
 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5549.788311 msecs

 Any thoughts about why this is the case?


There was a change for 1.5 to cache hasheq for maps 
https://github.com/clojure/clojure/commit/d77489d3ce912c177fe288a6f399a5c1da6683db
 
but the same is not done for defrecords. That is why maps are so much 
faster than records.


Paul

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-03 Thread Mark Engelberg
In these examples, the map/record is freshly created each time through the
loop, so caching should not be a factor.

In fact, later in the thread, AtKaaZ posted an example which demonstrated
his timing results when computing the hash repeatedly on the same object.
Oddly, the performance of hashing on maps got* worse *when repeatedly
hashing the same object (records were unaffected), implying that it was
taking more time to retrieve the cached hash than to just compute it from
scratch -- very strange.

--Mark

On Sun, Feb 3, 2013 at 4:47 PM, Paul Stadig p...@stadig.name wrote:

 On Sunday, February 3, 2013 1:07:41 AM UTC-5, puzzler wrote:

 I just went through the process of converting my map-based program over
 to records, hoping it would improve speed.  Much to my dismay, it actually
 slowed my program down substantially.  With some profiling, I discovered
 that one possible explanation is that (at least in RC4) hashing of records
 is about 60x slower than their map-based counterpart.

 (defrecord A [x y])
 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 90.631072 msecs
 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5549.788311 msecs

 Any thoughts about why this is the case?


 There was a change for 1.5 to cache hasheq for maps
 https://github.com/clojure/clojure/commit/d77489d3ce912c177fe288a6f399a5c1da6683dbbut
  the same is not done for defrecords. That is why maps are so much
 faster than records.


 Paul

  --
 --
 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.




Performance issue with hashing records

2013-02-02 Thread Mark Engelberg
I just went through the process of converting my map-based program over to
records, hoping it would improve speed.  Much to my dismay, it actually
slowed my program down substantially.  With some profiling, I discovered
that one possible explanation is that (at least in RC4) hashing of records
is about 60x slower than their map-based counterpart.

(defrecord A [x y])
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 90.631072 msecs
= (time (dotimes [n 1000] (hash (A. a 3
Elapsed time: 5549.788311 msecs

Any thoughts about why this is the case?

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-02 Thread Leonardo Borges
Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
got results similar to yours.

In Clojure 1.4, I get this:

user (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 5993.331 msecs
nil
user  (time (dotimes [n 1000] (hash (A. a 3
Elapsed time: 3144.368 msecs

No clue as to the reason though - but it seems something might have
changed from 1.4 to 1.5?


Leonardo Borges
www.leonardoborges.com


On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg mark.engelb...@gmail.com wrote:
 I just went through the process of converting my map-based program over to
 records, hoping it would improve speed.  Much to my dismay, it actually
 slowed my program down substantially.  With some profiling, I discovered
 that one possible explanation is that (at least in RC4) hashing of records
 is about 60x slower than their map-based counterpart.

 (defrecord A [x y])
 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 90.631072 msecs
 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5549.788311 msecs

 Any thoughts about why this is the case?

 --
 --
 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.




Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
he's in RC4
= *clojure-version*
{:major 1, :minor 5, :incremental 0, :qualifier RC4}

= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 70.037502 msecs

= (time (dotimes [n 1000] (hash (A. a 3
Elapsed time: 5307.93947 msecs


On Sun, Feb 3, 2013 at 8:22 AM, Leonardo Borges leonardoborges...@gmail.com
 wrote:

 Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
 got results similar to yours.

 In Clojure 1.4, I get this:

 user (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 5993.331 msecs
 nil
 user  (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 3144.368 msecs

 No clue as to the reason though - but it seems something might have
 changed from 1.4 to 1.5?


 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg mark.engelb...@gmail.com
 wrote:
  I just went through the process of converting my map-based program over
 to
  records, hoping it would improve speed.  Much to my dismay, it actually
  slowed my program down substantially.  With some profiling, I discovered
  that one possible explanation is that (at least in RC4) hashing of
 records
  is about 60x slower than their map-based counterpart.
 
  (defrecord A [x y])
  = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 90.631072 msecs
  = (time (dotimes [n 1000] (hash (A. a 3
  Elapsed time: 5549.788311 msecs
 
  Any thoughts about why this is the case?
 
  --
  --
  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.





-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-02 Thread Mark Engelberg
Clojure 1.5 RC-4

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
= (def m {:x a :y 3})
#'runtime.q_test/m
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 154.650091 msecs
nil
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 164.724641 msecs
nil
= (time (dotimes [n 1000] (hash m)))
Elapsed time: 150.194984 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 57.981602 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 70.803223 msecs
nil
= (time (dotimes [n 1000] (hash {:x a :y 3})))
Elapsed time: 67.395947 msecs
nil


= (def r (A. a 3))
#'runtime.q_test/r
= (time (dotimes [n 1000] (hash r)))
Elapsed time: 4906.641334 msecs
nil
= (time (dotimes [n 1000] (hash r)))
Elapsed time: 4959.124395 msecs
nil
= (time (dotimes [n 1000] (hash (A. a 3
Elapsed time: 4842.496589 msecs
nil
= (time (dotimes [n 1000] (hash (A. a 3
Elapsed time: 4856.855515 msecs
nil




On Sun, Feb 3, 2013 at 8:26 AM, AtKaaZ atk...@gmail.com wrote:

 he's in RC4
 = *clojure-version*
 {:major 1, :minor 5, :incremental 0, :qualifier RC4}


 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.037502 msecs


 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5307.93947 msecs


 On Sun, Feb 3, 2013 at 8:22 AM, Leonardo Borges 
 leonardoborges...@gmail.com wrote:

 Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
 got results similar to yours.

 In Clojure 1.4, I get this:

 user (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 5993.331 msecs
 nil
 user  (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 3144.368 msecs

 No clue as to the reason though - but it seems something might have
 changed from 1.4 to 1.5?


 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg mark.engelb...@gmail.com
 wrote:
  I just went through the process of converting my map-based program over
 to
  records, hoping it would improve speed.  Much to my dismay, it actually
  slowed my program down substantially.  With some profiling, I discovered
  that one possible explanation is that (at least in RC4) hashing of
 records
  is about 60x slower than their map-based counterpart.
 
  (defrecord A [x y])
  = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 90.631072 msecs
  = (time (dotimes [n 1000] (hash (A. a 3
  Elapsed time: 5549.788311 msecs
 
  Any thoughts about why this is the case?
 
  --
  --
  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.





 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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.




Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
ok i like this variant:
= (def r (memoize (A. a 3)))
#'runtime.q_test/r
= (time (dotimes [n 1000] (hash r)))
Elapsed time: 342.363961 msecs
nil
= (time (dotimes [n 1000] (hash r)))
Elapsed time: 361.66747 msecs
nil

= (time (dotimes [n 1000] (hash (memoize (A. a 3)
Elapsed time: 1812.016478 msecs
nil
= (time (dotimes [n 1000] (hash (memoize (A. a 3)
Elapsed time: 1847.244062 msecs
nil




On Sun, Feb 3, 2013 at 8:29 AM, AtKaaZ atk...@gmail.com wrote:

 = (def m {:x a :y 3})
 #'runtime.q_test/m
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 154.650091 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 164.724641 msecs
 nil
 = (time (dotimes [n 1000] (hash m)))
 Elapsed time: 150.194984 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 57.981602 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.803223 msecs
 nil

 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 67.395947 msecs
 nil


 = (def r (A. a 3))
 #'runtime.q_test/r
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4906.641334 msecs
 nil
 = (time (dotimes [n 1000] (hash r)))
 Elapsed time: 4959.124395 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4842.496589 msecs
 nil

 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 4856.855515 msecs
 nil




 On Sun, Feb 3, 2013 at 8:26 AM, AtKaaZ atk...@gmail.com wrote:

 he's in RC4
 = *clojure-version*
 {:major 1, :minor 5, :incremental 0, :qualifier RC4}


 = (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 70.037502 msecs


 = (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 5307.93947 msecs


 On Sun, Feb 3, 2013 at 8:22 AM, Leonardo Borges 
 leonardoborges...@gmail.com wrote:

 Are you running these in Clojure 1.5 RC-1 by any chance? That's when I
 got results similar to yours.

 In Clojure 1.4, I get this:

 user (time (dotimes [n 1000] (hash {:x a :y 3})))
 Elapsed time: 5993.331 msecs
 nil
 user  (time (dotimes [n 1000] (hash (A. a 3
 Elapsed time: 3144.368 msecs

 No clue as to the reason though - but it seems something might have
 changed from 1.4 to 1.5?


 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 3, 2013 at 5:07 PM, Mark Engelberg mark.engelb...@gmail.com
 wrote:
  I just went through the process of converting my map-based program
 over to
  records, hoping it would improve speed.  Much to my dismay, it actually
  slowed my program down substantially.  With some profiling, I
 discovered
  that one possible explanation is that (at least in RC4) hashing of
 records
  is about 60x slower than their map-based counterpart.
 
  (defrecord A [x y])
  = (time (dotimes [n 1000] (hash {:x a :y 3})))
  Elapsed time: 90.631072 msecs
  = (time (dotimes [n 1000] (hash (A. a 3
  Elapsed time: 5549.788311 msecs
 
  Any thoughts about why this is the case?
 
  --
  --
  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.





 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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