Part of the difference (under 1.2) is due to the (substantial) overhead of accessing the buffer-size var on every iteration.
I ran a quick check and using David's version of the code result averaged 17.2ms. Just changing buffer-size to a local with using (let [buffer-size (int 1920000)]...) the time dropped to an average 3.4ms. On Jan 29, 6:43 am, Benny Tsai <benny.t...@gmail.com> wrote: > On my home computer, using the same options, the java version runs in > 1.5 milliseconds, and David's 1.2 Clojure version in 16 milliseconds. > I'm at a loss as to why you're still seeing such a large gap between > the two versions. > > On Jan 28, 6:16 pm, Robert McIntyre <r...@mit.edu> wrote: > > > > > > > > > I'm running my JVM with: > > > -verbose:gc -Xmn500M -Xms2000M -Xmx2000M -server > > > sincerely, > > --Robert McIntyre > > > On Fri, Jan 28, 2011 at 4:24 PM, Benny Tsai <benny.t...@gmail.com> wrote: > > > Hi Robert, > > > > Just out of curiosity, are you running Clojure with the -server > > > option? When I run David's code, -server mode cuts the time for the > > > first run by half, and the time for subsequent runs by a factor of 5. > > > > On Jan 28, 12:36 pm, Robert McIntyre <r...@mit.edu> wrote: > > >> David, thanks for your suggestions. > > > >> I copied your code and tested it out, but on my machine it takes 230 > > >> milliseconds while the java version takes about 3. > > > >> If it's not too much trouble, how long does the java implementation > > >> take on your machine? > > > >> sincerely, > > >> --Robert McIntyre > > > >> On Fri, Jan 28, 2011 at 2:11 PM, David Nolen <dnolen.li...@gmail.com> > > >> wrote: > > >> > On Fri, Jan 28, 2011 at 2:01 PM, Aaron Cohen <aa...@assonance.org> > > >> > wrote: > > > >> >> On Fri, Jan 28, 2011 at 1:55 PM, David Nolen <dnolen.li...@gmail.com> > > >> >> wrote: > > >> >> > As a comparison, the following accomplishes the same thing in 1.3.0. > > >> >> > (ns test) > > >> >> > (set! *unchecked-math* true) > > >> >> > (set! *warn-on-reflection* true) > > >> >> > (def buffer-size 1920000) > > >> >> > (def array (byte-array buffer-size)) > > >> >> > (defn java-like [^bytes cpuArray] > > >> >> > (loop [i (int 0)] > > > >> >> Is this hint still necessary on 1.3.0? > > > >> > The int cast on 0 was an oversight on my part. It's not necessary. > > >> > David > > > >> > -- > > >> > 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 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 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