#!/bin/bash if [[ "$1" == '' ]]; then if [[ "$0" != *"bench.sh" ]]; then echo "usage: $0 bench " else echo "usage: $0 " fi exit 1 fi res=() uwu=0 function count() { x=0 for (( i=0; i<${#res[@]}; i++ )); do x=$((x+${res[i]})) done uwu=$((uwu+$((x/${#res[@]})))) echo "$((x/${#res[@]}))" res=() } function invoke() { ( time $@ ) 2>&1 | grep -a real | grep -aPoh "[^(real\t0m\.)].*[^s]" } echo "FFmpeg launch benchmark" echo -n "Burst... " for (( i=0; i<100; i++ )); do res+=($(invoke $1)) done count echo -n "Set sleep... " for (( i=0; i<25; i++ )); do res+=($(invoke $1)) sleep 0.1 done count echo -n "Random sleep... " for (( i=0; i<25; i++ )); do res+=($(invoke $1)) sleep 0.$((RANDOM%10)) done count echo "yeah, try $((uwu/3))"