OK, I incorporated some of the suggestions mentioned here, including the idea of using futures instead of agents.
Unfortunately, my script is now 3-4 times slower when using futures: http://gist.github.com/395153#file_pingdom_with_futures.clj I have a feeling it has something to do with the work being network I/ O bound rather than CPU bound -- something I noticed when using agents. The docs say when it's network I/O bound, to use send-off rather than just send when working with agents. But I see nothing about the type of work when dealing with futures. I'm sure I'm missing something. Thanks. On May 10, 1:46 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > 2010/5/10 Fabio Kaminski <fabiokamin...@gmail.com>: > > > in the following statement : > > "(4) Take a look at using futures instead of agents. " > > means futures are better than agents in all cases, or theres some particular > > cases? > > In this particular case. Because *directly* using agents, which carry > a bunch of "semantics" with them (serializing state modifications in > an asynchronous way), seems overkill just for fork-join style > parallelism. > > Futures, which still ensure that you will have work done in parallel > in several threads, while being able to wait for every of them being > done before continuing, are a closest fit. > > HTH, > > -- > Laurent > > > > > sorry about my laziness in not to hack the agents source.. but i thought it > > was better just to ask :) > > Thanks, > > Kaminski > > > On Mon, May 10, 2010 at 8:32 AM, patrik karlin <patrik.kar...@gmail.com> > > wrote: > > >> hello nott a expert my self > >> but #(:ip %) == :ip > >> and #(:exists %) == :exists > > >> witch seems more idiomatic > >> 2010/5/9 Tim Morgan <seve...@gmail.com> > > >>> I picked up Programming Clojure by Stuart Halloway last week and am > >>> working through the book. I'm coming from a Perl/Python/Ruby > >>> background, so Java + Lisp + functional programming is all new to me. > > >>> I thought a good exercise would be to write a script that pings all > >>> ips on a subnet looking for existing hosts, since I've written the > >>> same thing in Ruby before. > > >>> The script I came up with is here:http://gist.github.com/395153 > > >>> It works (and it's considerably faster than my Ruby equivalent!), but > >>> I'm not certain it's idiomatic Clojure, and would love if someone > >>> could critique me a bit. Tear it apart. > > >>> Thanks! > > >>> -Tim Morgan > > >>> -- > >>> 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 > > >> -- > >> ------------------------------------------------------------ > >> Patrik Kårlin > >> Mobil: 0735165903 > >> Email: patrik.kar...@gmail.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 > > > -- > > 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 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 > athttp://groups.google.com/group/clojure?hl=en -- 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