#!/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
