Tassilo Horn <tass...@member.fsf.org> writes:

> r-reduce> (let [f1 (apply comp* (take 1000000 (repeat inc)))
>                 f2 (apply comp (take 1000000 (repeat inc)))]
>             (bench (f1 0) :verbose)
>             (println "---------------------------------------")
>             (bench (f2 0) :verbose))

Oh, in this benchmark probably lazyness bites back.  In the `comp` case
the `reverse` call will create a realized seq whereas in the `comp*`
case the realization will take place not before the composition fn f1 is
applied.  However, forcing the realization beforehand doesn't make it
much better.

--8<---------------cut here---------------start------------->8---
user> (let [coll (doall (take 1000000 (repeat inc)))
           f1 (apply comp* coll) 
           f2 (apply comp coll)] 
        (bench (f1 0) :verbose) 
        (println "---------------------------------------")
        (bench (f2 0) :verbose))
amd64 Linux 3.4.2-gentoo 2 cpu(s)
OpenJDK 64-Bit Server VM 22.0-b10
Runtime arguments: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n 
-XX:+TieredCompilation -Xmx1G 
-Dclojure.compile.path=/home/horn/Repos/clj/testi/target/classes 
-Dtesti.version=0.1.0-SNAPSHOT -Dclojure.debug=false
Evaluation count             : 600
             Execution time mean : 112.324465 ms  95.0% CI: (112.247218 ms, 
112.380682 ms)
    Execution time std-deviation : 6.513809 ms  95.0% CI: (6.477450 ms, 
6.553029 ms)
         Execution time lower ci : 105.609401 ms  95.0% CI: (105.609401 ms, 
105.622918 ms)
         Execution time upper ci : 122.353763 ms  95.0% CI: (122.353763 ms, 
122.405315 ms)
---------------------------------------
amd64 Linux 3.4.2-gentoo 2 cpu(s)
OpenJDK 64-Bit Server VM 22.0-b10
Runtime arguments: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n 
-XX:+TieredCompilation -Xmx1G 
-Dclojure.compile.path=/home/horn/Repos/clj/testi/target/classes 
-Dtesti.version=0.1.0-SNAPSHOT -Dclojure.debug=false
Evaluation count             : 1440
             Execution time mean : 43.519663 ms  95.0% CI: (43.516732 ms, 
43.524062 ms)
    Execution time std-deviation : 492.299089 us  95.0% CI: (490.829889 us, 
494.198137 us)
         Execution time lower ci : 42.781398 ms  95.0% CI: (42.781398 ms, 
42.781398 ms)
         Execution time upper ci : 44.157311 ms  95.0% CI: (44.157311 ms, 
44.158513 ms)
nil
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo

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