Determine the maximum depth and path length within the current (or a specified) directory tree.
“There are older and fouler things than Orcs in the deep places of the world.”
— Gandalf, from “The Lord of the Rings: The Fellowship of the Ring”, by J.R.R. Tolkien
deepest — A cross-platform (and cross-language) command-line utility used to determine the maximum depth of the current (or a specified) directory tree.
Available in both Python and C++ flavors (via the ShedSkin libraries).
pip install deepest
git clone firstname.lastname@example.org:markgollnick/deepest.git cd deepest python setup.py build install # Alternatively... make python pip install dist/deepest-*.tar.gz
Once installed, you can use it as a script…
$ deepest . breadth of dirs examined longest pathname deepest directory 13 58 7 longest file: ./workspace/dwarves/digging/deep/deeper/deepest/balrog.log deepest path: ./workspace/some/really/long/directory/chain/here
…or, you can use it as a library:
>>> import deepest >>> deepest.get_depth('c:\\workspace') ('c:\\workspace\\some\\really\\long\\directory\\chain\\here', 7) >>> deepest.get_length('c:\\workspace') ('c:\\workspace\\dwarves\\digging\\deep\\deeper\\deepest\\balrog.log', 59)
Once compiled, it is a (notably faster) alternative to the Python script:
$ deepest c:\\workspace breadth of dirs examined longest pathname deepest directory 13 59 7 longest file: c:\workspace\dwarves\digging\deep\deeper\deepest\balrog.log deepest path: c:\workspace\some\really\long\directory\chain\here
In a project containing well over 5000 directories with a max depth of 13, the Python and C++ versions (compiled with clang-503.0.40) were pitted against each other. Both versions were run three times each on a Late 2013 Mac Book Pro.
These are the averaged results:
$ time deepest # Python script ... real 0m0.423s user 0m0.244s sys 0m0.160s $ time deepest # C++ binary ... real 0m0.169s user 0m0.063s sys 0m0.101s
In practical observation, using the compiled C++ version may gain you anywhere from a 10% to a whopping 60% boost in speed. :-)
Boost Software License, Version 1.0: <http://www.boost.org/LICENSE_1_0.txt>