2018-08-24 15:46:42 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
2018-10-08 15:55:35 +00:00
|
|
|
if [ "$1" = "--full" ]; then
|
|
|
|
FILE=$2
|
|
|
|
FULL=true
|
|
|
|
else
|
|
|
|
FILE=$1
|
|
|
|
FULL=false
|
|
|
|
fi
|
2018-08-24 15:46:42 +00:00
|
|
|
|
|
|
|
echo 'Tokei Benchmarking Tool'
|
|
|
|
|
|
|
|
if [ $FULL = true ]; then
|
2018-08-25 20:10:34 +00:00
|
|
|
REQUIRED='cloc, tokei, loc, hyperfine, and scc'
|
2018-08-24 15:46:42 +00:00
|
|
|
else
|
2018-08-25 20:10:34 +00:00
|
|
|
REQUIRED='tokei, and hyperfine'
|
2018-08-24 15:46:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "The use of this tool requires $REQUIRED to be installed and available in your PATH variable."
|
|
|
|
|
|
|
|
echo 'Please enter the path you would like to benchmark:'
|
|
|
|
|
2018-10-08 15:55:35 +00:00
|
|
|
if [ -z ${FILE+x} ]; then
|
2020-11-30 06:56:58 +00:00
|
|
|
read -r input
|
2018-10-08 15:55:35 +00:00
|
|
|
else
|
|
|
|
input=$FILE
|
|
|
|
fi
|
2018-08-24 15:46:42 +00:00
|
|
|
|
|
|
|
hyperfine --version
|
|
|
|
echo "old tokei: $(tokei --version)"
|
|
|
|
|
|
|
|
if [ $FULL = true ]; then
|
2018-08-25 20:10:34 +00:00
|
|
|
scc --version
|
2018-08-24 15:46:42 +00:00
|
|
|
loc --version
|
2018-08-25 20:10:34 +00:00
|
|
|
echo "cloc: $(cloc --version)"
|
2018-08-24 15:46:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cargo build --release
|
|
|
|
|
|
|
|
if [ $FULL = true ]; then
|
2020-03-21 11:57:40 +00:00
|
|
|
hyperfine -w 10 --export-csv './results.csv' "target/release/tokei $input" \
|
2018-08-25 20:10:34 +00:00
|
|
|
"tokei $input" \
|
|
|
|
"scc $input" \
|
2020-03-21 11:57:40 +00:00
|
|
|
"loc $input" # \ "cloc $input"
|
2018-08-24 15:46:42 +00:00
|
|
|
else
|
2020-03-21 11:57:40 +00:00
|
|
|
hyperfine -w 5 "target/release/tokei $input" \
|
2018-08-25 20:10:34 +00:00
|
|
|
"tokei $input"
|
2018-08-24 15:46:42 +00:00
|
|
|
fi
|