Hi all,

Noticed in Clojure 1.3-Alpha8 that there is a large difference in speed when 
adding two Short/TYPE arrays rather than two Integer/TYPE java arrays. Is 
that something related to clojure, my code, or just a CPU-related thing when 
it comes to summing. I'd like to save some memory by using shorts, but for 
now that is too much of a speed sacrifice.

Using criterium, the difference 
* adding int arrays: Execution time mean          : 111.429525 us  95.0% CI: 
(111.426342 us, 111.432155 us)   
* adding short arrays: Execution time mean          : 226.836034 ms  95.0% 
CI: (226.824310 ms, 226.846928 ms)

(I saw no such difference in adding or multiplying floats vs doubles)

Code: 

(defn plusS ^shorts [^shorts array ^shorts arr2]                             
                                                                            
                                       
  "adds two Short arrays"                                                   
                                                                            
                                        
  (amap array idx ret (short (+ (aget array idx) (aget arr2 idx)))))         
                                                                            
                                       
                                                                            
                                                                            
                                        
(defn plusI ^ints [^ints array ^ints arr2]                                   
                                                                            
                                       
  "adds two Int arrays."                                                     
                                                                            
                                       
  (amap array idx ret (+ (aget array idx) (aget arr2 idx))))   

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

Reply via email to