-
-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathbench-cmd
More file actions
executable file
·18 lines (18 loc) · 602 Bytes
/
bench-cmd
File metadata and controls
executable file
·18 lines (18 loc) · 602 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env bash
# Benchmark a command as a string and output results
# to a file with format:
#
# cmd <command run>
# time <time in seconds to finish>
# exit_status <exit status>
set -eu
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
# Command to benchmark
cmd="$1"
shift
# Where to append write results to. Default: /dev/null.
results_file="${1:-/dev/null}"
mkdir -p "$(dirname "$results_file")"
printf 'cmd ' >> "$results_file"
env time --append -f 'time %e' --output="$results_file" "${root_dir}/eeval" -a "$cmd" "$results_file"
printf "exit_status $?\n" >> "$results_file"