Skip to content

Instantly share code, notes, and snippets.

@menny
Last active January 28, 2019 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menny/0eb47e8e5e60a4167516a9e9193e8a00 to your computer and use it in GitHub Desktop.
Save menny/0eb47e8e5e60a4167516a9e9193e8a00 to your computer and use it in GitHub Desktop.
git status pref script
#!/bin/bash
command -v gtime >/dev/null 2>&1 || { echo >&2 "GNU time is required. Install it through 'brew install gnu-time'. Aborting."; exit 1; }
command -v rs-git-fsmonitor >/dev/null 2>&1 || { echo >&2 "rs-git-fsmonitor is required. Read https://github.com/jgavris/rs-git-fsmonitor#installation for how to install. Aborting."; exit 1; }
if [[ "${USER}" != "root" ]]; then
echo "Run this script as root, since we need to call dtruss during the script."
exit 1
fi
if [[ ! -d "$1" ]]; then
echo "First argument must point to a git repo folder to benchmark on"
exit 1
fi
pushd $1
function timing_dtruss() {
echo "dtruss $1"
git clean -fd && git reset --hard HEAD
echo "No changes timing"
dtruss git status 2>&1 | grep stat64 | wc -l
dtruss git status 2>&1 | grep stat64 | wc -l
touch just_one_empty_file
echo "One file timing"
dtruss git status 2>&1 | grep stat64 | wc -l
dtruss git status 2>&1 | grep stat64 | wc -l
for i in `seq 1 50`;
do
echo "data $i" > temp_file_$i
done
echo "Many files timing"
dtruss git status 2>&1 | grep stat64 | wc -l
dtruss git status 2>&1 | grep stat64 | wc -l
echo "Staged many files"
dtruss git add . 2>&1 | grep stat64 | wc -l
echo "Staged many timing"
dtruss git status 2>&1 | grep stat64 | wc -l
dtruss git status 2>&1 | grep stat64 | wc -l
}
function timing_gtime() {
echo "gtime $1"
git clean -fd && git reset --hard HEAD
echo "No changes timing"
gtime --format="%E" git status > /dev/null
gtime --format="%E" git status > /dev/null
touch just_one_empty_file
echo "One file timing"
gtime --format="%E" git status > /dev/null
gtime --format="%E" git status > /dev/null
for i in `seq 1 50`;
do
echo "data $i" > temp_file_$i
done
echo "Many files timing"
gtime --format="%E" git status > /dev/null
gtime --format="%E" git status > /dev/null
echo "Staged many files"
gtime --format="%E" git add .
echo "Staged many timing"
gtime --format="%E" git status > /dev/null
gtime --format="%E" git status > /dev/null
}
git config --unset core.fsmonitor
timing_dtruss "No fs-notifier"
timing_gtime "No fs-notifier"
git config core.fsmonitor rs-git-fsmonitor
timing_dtruss "rs-git-notifier"
timing_gtime "rs-git-notifier"
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment