timing for map

2009-06-07 Thread artg

user= (time (map answer '(50 50)))
Elapsed time: 0.032826 msecs
(392330 392711)
user= (time (answer 50))
Elapsed time: 6357.131423 msecs
392849

When I try to time 'map' it seems to return right away.  How do I time
the full two executions of 'answer'?

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



Re: timing for map

2009-06-07 Thread Kyle R. Burton

I map produces a lazy sequence, time doesn't force it, if you wrap it
in either a dorun or doall, you should get what you expect:

user (time (map #(Thread/sleep %) '(1000 1000 1000)))
Elapsed time: 0.156 msecs
(nil nil nil)
user (time (doall (map #(Thread/sleep %) '(1000 1000 1000
Elapsed time: 3000.383 msecs
(nil nil nil)
user



I think that is what you're running into.


Kyle

On Sat, Jun 6, 2009 at 5:02 PM, artg artgittle...@gmail.com wrote:

 user= (time (map answer '(50 50)))
 Elapsed time: 0.032826 msecs
 (392330 392711)
 user= (time (answer 50))
 Elapsed time: 6357.131423 msecs
 392849

 When I try to time 'map' it seems to return right away.  How do I time
 the full two executions of 'answer'?

 




-- 
--
kyle.bur...@gmail.comhttp://asymmetrical-view.com/
--

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