Hey, I'm actually surprised you get to "stop" at all. You send a couple items onto the channel but don't close it, therefore the 2nd go block will potentially block forever waiting for more.
I'm far from an expert in core.async but I think the solution would be to close! the channel and as a suggestion: (go) blocks themselves return channels that "block" until they are completed. You could write this as: (time (let [c (chan 100)] (go (dotimes [i 100000] (>! c i)) (close! c)) ;; go and wait for its result (<!! (go (while (<! c)) :done)))) HTH, /thomas On Friday, November 29, 2013 5:08:52 AM UTC+1, kandre wrote: > > Hi there, > I've started playing with core.async but I am not sure if I'm using it the > way it was intended to. > Running a simple benchmark with two go-blocks (one writing an event to a > channel, the other one reading it out) seems quite slow: > > (time (let [c (chan 100) stop (chan)] > (go > (dotimes [i 100000] > (>! c i))) > (go > (while (<! c)) > (>! stop true)) > (<!! stop))) > > "Elapsed time: 1226.072003ms" > > I presume the way I am using core.async is fundamentally flawed so I'd be > greatful if someone would point it out to me. > > Cheers > Andreas > -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.