/usr/bin/find slow with some options

Today I tried to run a simple find command in Iterm, and found it to be unusably slow even for simple queries. Here's the simplest example:

time find . -depth 0
.

real    0m11.056s
user    0m0.571s
sys 0m5.186s

I get similar results from any directory, and whether using ITerm, Terminal, or VS Code's integrated terminal. I'm not setting any find or file system options in my .bash_profile or other startup scripts.

What could be slowing it down?

  • Big Sur: 11.2.3
  • Iterm: 3.4.8
  • Terminal: 2.11
  • shell: bash 5.1.4(1)-release via homebrew
  • VS Code: 1.57.1

Okay, this was simple user error. The option I should have been using was -maxdepth n, not -depth n. Instead of only searching the directories of interest, -depth n recursively searches the entire tree starting from the specified directory, and only matches those at that are n directories deep. And the issue was not from any directory, all the directories I tried before asking the question contained a lot of child directories and files.