Idiomatic clojure for progress reporting?

后端 未结 4 2054
醉酒成梦
醉酒成梦 2020-12-13 00:50

How should I monitor the progress of a mapped function in clojure?

When processing records in an imperative language I often print a message every so often to indica

4条回答
  •  遥遥无期
    2020-12-13 01:12

    I have had this problem with some slow-running apps (e.g. database ETL, etc). I solved it by adding the function (tupelo.misc/dot ...) to the tupelo library. Sample:

    (ns xxx.core 
      (:require [tupelo.misc :as tm]))
    
    (tm/dots-config! {:decimation 10} )
    (tm/with-dots
      (doseq [ii (range 2345)]
        (tm/dot)
        (Thread/sleep 5)))
    

    Output:

         0 ....................................................................................................
      1000 ....................................................................................................
      2000 ...................................
      2345 total
    

    API docs for the tupelo.misc namespace can be found here.

提交回复
热议问题