Created
March 3, 2020 23:54
-
-
Save camsaul/4c6d0dc9f9bce520be951bdcdd1a91b0 to your computer and use it in GitHub Desktop.
Print all threads grouped by pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn- all-threads [] | |
(transduce | |
identity | |
(fn | |
([] | |
{}) | |
([m] | |
(into (flatland.ordered.map/ordered-map) | |
(cons | |
[:total (reduce + (vals m))] | |
(sort-by #(- (second %)) m)))) | |
([m ^Thread thread] | |
(let [thread-name (clojure.string/replace (.getName thread) #"\d+" "")] | |
(update m thread-name (fnil inc 0))))) | |
(keys (Thread/getAllStackTraces)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment