[英]Performance counter for Clojure (using core.async)
I am wondering what is the best way to implement performance counters in Clojure for a particular task that runs concurrently. 我想知道对于同时运行的特定任务,在Clojure中实现性能计数器的最佳方法是什么。
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.
缩进代码以提高可读性。
Have you considered ztellman's Narrator . 您是否考虑过ztellman的旁白 。 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. 我实际上并没有使用过它,只是记得阅读过它的文档,并且内置了这种聚合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.