~kris/dots

srice

srice/.local/bin/benchit -rw-r--r-- 480 bytes
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# benchit -- quick benchmark wrapper around hyperfine
# Usage: benchit <command>
#        benchit -n 100 <command>
#        benchit -c <cmd1> <cmd2>  (compare two commands)

if [ "$1" = "-c" ]; then
    shift
    cmd1="$1"; cmd2="$2"
    [ -z "$cmd2" ] && { echo "Usage: benchit -c <cmd1> <cmd2>"; exit 1; }
    hyperfine --warmup 3 "$cmd1" "$cmd2"
elif [ "$1" = "-n" ]; then
    shift; n="$1"; shift
    hyperfine --runs "$n" "$*"
else
    hyperfine --warmup 3 "$*"
fi