I've been doing some code profiling lately, and I made one small change that drastically improved performance.
I had this function: (defn run-systems "Run the systems in the order specified over the cross-map specified." ([cm] (run-systems system-order cm)) ([order cm] (reduce (fn [acc f] (->> (get-profile f) (cross-cols acc) (mapcat (comp entity-pairs f)) (into cm ))) cm order))) Executing this function 1000 times in a row gives a runtime of about 218 ms. By making a small change and using mapcat as a transducer: (defn run-systems "Run the systems in the order specified over the cross-map specified." ([cm] (run-systems system-order cm)) ([order cm] (reduce (fn [acc f] (->> (get-profile f) (cross-cols acc) (into cm (mapcat (comp entity-pairs f))))) cm order))) The runtime goes all the way down to 169 ms. I knew that removing intermediate collections helped performance, but I wasn't expecting such a drastic improvement. Does anyone know similar simple tricks (either transducer-related or not transducer-related) that could further improve performance of these types of operations? (Runtime results are averaged over many runs using the criterium profiling library, so it's not just a fluke of thread scheduling). -- 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/d/optout.