Thanks Benny. I tried again without using cake and just compiling the
code into a jar and it does execute much better. I guess using the
cake run command as a way to avoid the JVM startup overhead isn't the
best option for writing highly performant code. I was kind of hoping
that after the first run, cake was compiling the code and loading the
classes into the running JVM to avoid most of the overhead of a fresh
startup, but I guess it is instead executing it as a script or
something. Good to know!

Thanks.

On Jul 8, 5:44 pm, Benny Tsai <benny.t...@gmail.com> wrote:
> Hi Christopher,
>
> I ran your code with only one modification, using the "time" macro to
> measure the execution time of the mapper function itself:
>
> (use ['clojure.java.io :only '(reader)])
> (use ['clojure.string :only '(split)])
>
> (defn mapper [lines]
>   (doseq [line lines]
>     (doseq [word (split line #"\s+")]
>       (println (str word "\t1")))))
>
> (time (mapper (line-seq (reader *in*))))
>
> Processing a file that contained 1 copy of the "Hound of Baskerville" text
> took 1.9 seconds.
> Processing a file that contained 2 copies of the text took 2.8 seconds.
> Processing a file that contained 4 copies of the text took 3.8 seconds.
>
> I did not use cake, but ran mapper.clj via a direct call to the java
> executable.  So I think the times you're seeing is due to either Cake or the
> way the timing is done.

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