find_git_dirs.clj
This file contains 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
(require '[babashka.fs :as fs]) | |
(let [counter (volatile! 0)] | |
(fs/walk-file-tree "." {:pre-visit-dir (fn [d _] | |
(if (= ".git" (fs/file-name d)) | |
(do (vswap! counter inc ) | |
:skip-subtree) | |
:continue))}) | |
@counter) | |
;; $ time bb /tmp/find_git_dirs.clj | |
;; 136 | |
;; bb /tmp/find_git_dirs.clj 0.23s user 0.63s system 99% cpu 0.861 total | |
;; $ time find . -type d -name .git | wc -l | |
;; 136 | |
;; find . -type d -name .git 0.16s user 1.63s system 75% cpu 2.377 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment