1#!/usr/bin/env bash
2set -e
3
4if [ "$1" = "--full" ]; then
5    FILE=$2
6    FULL=true
7    else
8    FILE=$1
9    FULL=false
10fi
11
12echo 'Tokei Benchmarking Tool'
13
14if [ $FULL = true ]; then
15    REQUIRED='cloc, tokei, loc, hyperfine, and scc'
16else
17    REQUIRED='tokei, and hyperfine'
18fi
19
20echo "The use of this tool requires $REQUIRED to be installed and available in your PATH variable."
21
22echo 'Please enter the path you would like to benchmark:'
23
24if [ -z ${FILE+x} ]; then
25    read -r input
26else
27    input=$FILE
28fi
29
30hyperfine --version
31echo "old tokei: $(tokei --version)"
32
33if [ $FULL = true ]; then
34    scc --version
35    loc --version
36    echo "cloc: $(cloc --version)"
37fi
38
39cargo build --release
40
41if [ $FULL = true ]; then
42    hyperfine -w 10 --export-csv './results.csv' "target/release/tokei $input" \
43                "tokei $input" \
44                "scc $input" \
45                "loc $input" # \ "cloc $input"
46else
47    hyperfine -w 5 "target/release/tokei $input" \
48                "tokei $input"
49fi
50