#!/usr/bin/awk -f #------------------------------------------------------------------------------ # Initialization: #------------------------------------------------------------------------------ BEGIN { line = 0; benchmark = ""; runs = 0; load = 0; exec = 0; total = 0; time_user = 0; time_sys = 0; time_real = 0; mem = 0; } #------------------------------------------------------------------------------ # Process Line: #------------------------------------------------------------------------------ { # Are the results for a new benchmark? Then output averages. if(benchmark != "" && benchmark != $1) { printf("Bench: %s\n", benchmark); printf("Runs: %4d\n", runs); printf("Load: %8.3f s\n", (load/runs)/1000); printf("Exec: %8.3f s\n", (exec/runs)/1000); printf("Total: %8.3f s\n", (total/runs)/1000); printf("User: %8.3f s\n", (time_user/runs)); printf("Sys: %8.3f s\n", (time_sys/runs)); printf("Real: %8.3f s\n", (time_real/runs)); printf("Mem: %8.3f MB\n", (mem/runs)/1000); printf("\n"); } # If benchmark is not set: Initialize everything (make sums zero): if(benchmark != $1) { benchmark = $1; runs = 0; load = 0; exec = 0; total = 0; time_user = 0; time_sys = 0; time_real = 0; mem = 0; } # Process this benchmark line: line++; runs++; load += $2; exec += $3; total += $4; time_user += $6; time_sys += $7; mem += $9; # $8 (Elapsed Time = Realtime) has the format 0:00.02 pos_colon = index($8, ":"); len = length($8); if(pos_colon <= 0) print "Format error in elapsed time in line " line; else { min = substr($8, 1, (pos_colon - 1)); sec = substr($8, (pos_colon + 1), (len - pos_colon)); time_real += (min * 60 + sec); } } #------------------------------------------------------------------------------ # At End of File: #------------------------------------------------------------------------------ END { if(runs > 0) { printf("Bench: %s\n", benchmark); printf("Runs: %4d\n", runs); printf("Load: %8.3f s\n", (load/runs)/1000); printf("Exec: %8.3f s\n", (exec/runs)/1000); printf("Total: %8.3f s\n", (total/runs)/1000); printf("User: %8.3f s\n", (time_user/runs)); printf("Sys: %8.3f s\n", (time_sys/runs)); printf("Real: %8.3f s\n", (time_real/runs)); printf("Mem: %8.3f MB\n", (mem/runs)/1000); printf("\n"); } print line " benchmark results read in total"; }