~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/benchit -rwxr-xr-x 480 bytes
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 2 months 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