0

I am wondering what is the best way to implement performance counters in Clojure for a particular task that runs concurrently.

I usually end up having something like this:

(defn -main [& args]
  (let [c (async/chan)]
    (doseq [_ (range 50)]
      (async/thread
        (async/>!! c

              (doseq [r (chunk-of-work)]
                (println r)
                (doall (pmap #(work %) r))))

        )
      )
    )

 (while true
      (async/<!! c))
  )
)

What would be the best way of counting how many messages I am getting through the channel every second? The code is indented for better readability.

Istvan
  • 6,372
  • 7
  • 43
  • 81

1 Answers1

1

Have you considered ztellman's Narrator. It's a package for

"analyzing and aggregating streams of data"

There's plenty of examples, including one for the rate of messages over a period.

I haven't actually used it, just remembered reading its docs and it having this kind of aggregation build in.

Mark Fisher
  • 9,198
  • 3
  • 30
  • 38