Why is `brew` extremely slow? When I run brew --version, it took 30 seconds to return a response. Other brew commands are even slower. My CPU is ~ 90% idle. All other programs are running perfectly fine on my machine. I have the latest version of brew, and brew doctor passes.

Any ideas on what I can try (other than reboot the machine)?

$ brew --version
Homebrew 1.5.4
Homebrew/homebrew-core (git revision bda76; last commit 2018-02-26)

$ brew doctor
Your system is ready to brew.

$ brew config
HOMEBREW_VERSION: 1.5.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: 021fe22e3c982b08346422d1e7897e929a709380
Last commit: 2 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bda76108c4f452684682a89f1d7fb7cd4acf8557
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.3.3 =&gt; /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.15.0 =&gt; /usr/local/bin/git
Curl: 7.54.0 =&gt; /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby =&gt; /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: N/A
macOS: 10.12.6-x86_64
Xcode: N/A
CLT: 9.2.0.0.1.1510905681
X11: N/A
It looks like a network issue.
In such cases when I use a framework that is dependant on the internet I would run a ping test which can give a clue on what's happening on the network layer (any delays or such)