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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.