Hi Tim,
Thanks for the feedback and for taking the time to read the article. I
realized that pmap was probably a better solution as I was writing the
code, but pmap doesn't make for much of an agent demo, so I carried on
with my original plan. The point you make about bucketing is very
interesting. I guess I should have realized that the underlying thread
pool would do a better job on it's own. It's good to know because that
means even less work down the road ;-). On benchmarking, I'm sure
there are a number of faster ways to do this than my example provides.
The main goal was really just a clear example on agent usage, but it's
really nice that Clojure gives you so much flexibility when it comes
to performance (even with micro-benchmarks).

Travis

On Jun 19, 3:59 am, Timothy Pratley <[email protected]> wrote:
> > Feedback is always welcome.
>
> Very entertaining! :)
>
> Bucketing is actually counter productive in your example. send already
> takes care of limiting the active threads by using a thread pool, and
> can ballance the work better than bucketing. When I run your code
> unchanged it takes 2400ms, if I set the number of buckets equal to the
> number of tasks, it runs in 2200ms.
>
> However for this sort of problem I don't think agents are the right
> way to model it, as you aren't really tracking a state. You can use
> the inbuilt pmap for this sort of 'computation chunks' problem:
> (doseq [r (pmap decode-md5 work-units)]
>   (println r))
> Executes in 1400ms for me.
>
> Of course benchmarks are fickle things - my main point is that
> asthetically agents are an unnecessary complication here. Of course
> its still great as an example of how they work :)
>
> Regards,
> Tim.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to