#!/usr/bin/env bash ./build.sh clean ./build.sh profile ./mknes ./build.sh profile_release runs=10 frames=4096 events="cycles,instructions,task-clock" tmp=$(mktemp) taskset -c 1 ./mknes > "$tmp" for i in $(seq 1 $runs); do taskset -c 1 chrt -f 99 perf stat -x, -e $events -- ./mknes 2>>"$tmp" done awk -F, -v F="$frames" ' $3=="cycles" { c[++nc]=$1/F } $3=="instructions" { i[++ni]=$1/F } # $3=="task-clock" { t[++nt]=$1 } # milliseconds NOTE(peter): changed to nanoseconds... $3=="task-clock" { t[++nt]=$1/1000000 } END { for(k=1;k<=nc;k++) sumc+=c[k]; mc=sumc/nc for(k=1;k<=ni;k++) sumi+=i[k]; mi=sumi/ni for(k=1;k<=nt;k++) sumt+=t[k]; mt=sumt/nt for(k=1;k<=nc;k++) sdc+=(c[k]-mc)^2; sdc=sqrt(sdc/(nc-1)) for(k=1;k<=ni;k++) sdi+=(i[k]-mi)^2; sdi=sqrt(sdi/(ni-1)) for(k=1;k<=nt;k++) sdt+=(t[k]-mt)^2; sdt=sqrt(sdt/(nt-1)) ms_per_frame = mt / F fps = F / (mt / 1000) printf "IPC (insn/cycle) = %.3f\n", mi/mc printf "cycles/frame mean=%.0f sd=%.0f relSD=%.3f%% n=%d\n", mc, sdc, 100*sdc/mc, nc printf "insn/frame mean=%.0f sd=%.0f relSD=%.3f%% n=%d\n", mi, sdi, 100*sdi/mi, ni printf "time (ms) mean=%.3f sd=%.3f relSD=%.3f%% n=%d\n", mt, sdt, 100*sdt/mt, nt printf "FPS (frames/second) = %.2f\n", fps printf "ms/frame = %.6f\n", ms_per_frame }' "$tmp"