Skip to content

Instantly share code, notes, and snippets.

@ymyzk
Last active August 29, 2015 14:14
Show Gist options
  • Save ymyzk/5441e5512bbc63e6f0ff to your computer and use it in GitHub Desktop.
Save ymyzk/5441e5512bbc63e6f0ff to your computer and use it in GitHub Desktop.
Comparison of 'which', 'command -v', 'type' and 'hash'
query=vim
time bash -c "for i in {0..1000}; do which $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do command -v $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do type $query; done >/dev/null 2>&1"
time bash -c "for i in {0..1000}; do hash $query; done 2>/dev/null"
time zsh -c "for i in {0..100000}; do which $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do command -v $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do type $query; done >/dev/null 2>&1"
time zsh -c "for i in {0..100000}; do hash $query; done 2>/dev/null"
@ymyzk
Copy link
Author

ymyzk commented Jan 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment