Profiling: make larger call numbers easier to read

This commit is contained in:
Peter Taoussanis 2014-03-17 00:43:54 +07:00
parent c05e980e8a
commit 54197c1dec
2 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@
* [#60] CHANGE: `defnp` no longer generates an Eastwood warning (ducky427). * [#60] CHANGE: `defnp` no longer generates an Eastwood warning (ducky427).
* CHANGE: Improved profiling memory efficiency (max memory use, was previously unbounded). * CHANGE: Improved profiling memory efficiency (max memory use, was previously unbounded).
* CHANGE: Profiling: make larger call numbers easier to read.
## v3.1.6 / 2014 Mar 16 ## v3.1.6 / 2014 Mar 16

View File

@ -186,8 +186,8 @@
accounted (reduce + (map :time (vals stats))) accounted (reduce + (map :time (vals stats)))
max-id-width (apply max (map (comp count str) max-id-width (apply max (map (comp count str)
(conj (keys stats) "Accounted Time"))) (conj (keys stats) "Accounted Time")))
pattern (str "%" max-id-width "s %6d %9s %10s %9s %9s %7d %1s%n") pattern (str "%" max-id-width "s %,11d %9s %10s %9s %9s %7d %1s%n")
s-pattern (.replace pattern \d \s) s-pattern (str "%" max-id-width "s %11s %9s %10s %9s %9s %7s %1s%n")
perc #(Math/round (/ %1 %2 0.01)) perc #(Math/round (/ %1 %2 0.01))
ft (fn [nanosecs] ft (fn [nanosecs]
(let [pow #(Math/pow 10 %) (let [pow #(Math/pow 10 %)
@ -199,7 +199,7 @@
:else (str nanosecs "ns"))))] :else (str nanosecs "ns"))))]
(with-out-str (with-out-str
(printf s-pattern "Id" "Calls" "Min" "Max" "MAD" "Mean" "Time%" "Time") (printf s-pattern "Id" "nCalls" "Min" "Max" "MAD" "Mean" "Time%" "Time")
(doseq [pid (->> (keys stats) (doseq [pid (->> (keys stats)
(sort-by #(- (get-in stats [% (or sort-field :time)]))))] (sort-by #(- (get-in stats [% (or sort-field :time)]))))]
(let [{:keys [count min max mean mad time]} (stats pid)] (let [{:keys [count min max mean mad time]} (stats pid)]