As with most microbenchmarks you're measuring the test more than the
subject.  In the above case the seq generation dominates.

Compare the following on my machine:
user=> (time (doseq [x (range 100000)] (bit-shift-left x 1)))
"Elapsed time: 3531.198 msecs"
nil
user=> (time (dotimes [x 100000] (bit-shift-left x 1)))
"Elapsed time: 3.744 msecs"
nil

Beyond the seq issue there is a further (very small) penalty due to
seqs working with objects, thus x from the range seq is a Long object,
not a primitive long.  You can see the implementation differences of
shiftLeft here:
http://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L425





On Sep 29, 11:19 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> bitwise-and and bitwise-shift-right and bitwise-shift-left run more
> than 50 times slower in clojure 1.3 alpha 1 versus clojure 1.2.  Could
> the 1.3 gurus please investigate this?
>
> Try something like this to see the difference:
> (time (doseq [x (range 100000)] (bit-shift-left x 1)))
>
> This points to another issue with Clojure 1.3.  I can't figure out how
> to determine what is a primitive and what isn't.  Are the values
> produced by range primitives?  Are the values produced by bitwise
> operations primitive?  How can I determine this?

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