#!/usr/bin/awk -f # Caller must set nbscript and path values on the command line. # Example: compute_global_stats.awk -v path=2001-10-10@14:55:23/ -v nbscript=2 2001-10-10@14:55:23/stat_client0.html BEGIN { printf "Computing global stats for "nbscript" scripts in "path" ..."; outputFile = path"perf.html"; footer = 0; headerRow = 0; for (i = 1 ; i < nbscript ; i++) scriptName[i] = path"stat_client"i".html"; } { # Read each line from all files to be synchronized between them line[0] = $0; for (i = 1 ; i < nbscript ; i++) getline line[i] < scriptName[i]; # Compute the global results for the statistics of each ramp if (headerRow == 1) { if ($0 ~ "
Total
") { # This is the total line, compute the percentages and print the table totalCount = 0; totalErrors = 0; totalTime = 0; for (i = 0 ; i < nbscript ; i++) { split(line[i], splited, ""); gsub(/
||<\/B>/, "", splited[3]); # Get rid of the '
' and totalCount += splited[3]; gsub(/
||<\/B>/, "", splited[4]); # Get rid of the '
' and totalErrors += splited[4]; } if (totalCount == 0) totalCount = 1000000000000000000000000; # make totalCount infinite so that division result will give 0. for (i = 0 ; (i < stateNb) && (stateNb != 0); i++) { if (count[i] != 0) { printf "%s
%.2f %%
%d
%d
%d ms
%d ms
%.0f ms
\n", stateName[i], 100*count[i]/totalCount, count[i], errors[i], minTime[i], maxTime[i], avgTime[i]/count[i] >> outputFile; totalTime += avgTime[i]; } } # Display the total if (stateNb == 0) stateNb = 1000000000000000000000000; # make stateNb infinite so that division result will give 0. printf "
Total
100 %%
%d
%d
-
-
%.0f ms
", totalCount, totalErrors, totalTime/totalCount >> outputFile; } else if ($0 ~ "
Average throughput
") { # Average throughput throughput = 0; for (i = 0 ; i < nbscript ; i++) { split(line[i], splited, /|<\/B>/); gsub(/ req\/s/, "", splited[4]); # Get rid of the '< req/s>' throughput += splited[4]; } print "
Average throughput
"throughput" req/s
" >> outputFile; } else if ($0 ~ "
Completed sessions
") { # Completed sessions sessions = 0; for (i = 0 ; i < nbscript ; i++) { split(line[i], splited, /
/); gsub(/<\/div>/, "", splited[3]); # Get rid of the '
' sessions += splited[3]; } print "
Completed sessions
"sessions"
" >> outputFile; } else if ($0 ~ "
Total time
") { # Total time time = 0; for (i = 0 ; i < nbscript ; i++) { split(line[i], splited, /
/); gsub(/ seconds<\/div>/, "", splited[3]); # Get rid of the '
' time += splited[3]; } print "
Total time
"time" seconds
" >> outputFile; } else if ($0 ~ "
Average session time
") { # Average session time is the last stat of the table, we close the table here. if (time == 0) print "
Average session time
0 second
" >> outputFile; else print "
Average session time
"time/sessions" seconds
" >> outputFile; print "

" >> outputFile; headerRow = 0; } else if ($0 ~ "align=right>") { # We have to process a stat line, let's go ! count[stateNb] = 0; errors[stateNb] = 0; minTime[stateNb] = 1000000000000000; maxTime[stateNb] = 0; avgTime[stateNb] = 0; for (i = 0 ; i < nbscript ; i++) { split(line[i], splited, "

"); if (i == 0) stateName[stateNb] = splited[1]; else if (splited[1] != stateName[stateNb]) print "Error line "NR" in "path"stat_client"i".html: Bad state '"splited[1]"' does not match '"stateName[stateNb]"'"; # Skip percentage in splited[2], we'll have to compute that later count[stateNb] += splited[3]; gsub(/|<\/B>/, "", splited[4]); # Get rid of the '' and errors[stateNb] += splited[4]; sub(/ ms/, "", splited[5]); # Get rid of the ' ms' if (minTime[stateNb] > (splited[5]+0)) { minTime[stateNb] = splited[5] +0; } if (maxTime[stateNb] < (splited[6]+0)) maxTime[stateNb] = (splited[6]+0); sub(/ ms<\/div>/, "", splited[7]); # Get rid of the ' ms
' avgTime[stateNb] += splited[7] * splited[3]; } stateNb++; } } # Print the headers for ramps if ($0 ~ /stat\"><\/A>|statistics<\/h3>

/) { print $0 >> outputFile; testTiming = 0; } # Print a summary of 'Test timing information' for all clients if ($0 ~ "") testTiming = 1; if (testTiming == 1) { if ($0 ~ "") { printf $0 >> outputFile; for (i = 1 ; i < nbscript ; i++) { split(line[i], splited, ""); printf ""splited[3] >> outputFile; } print "" >> outputFile; } else print $0 >> outputFile; if ($0 ~ "PhaseMain client" >> outputFile; for (i = 1 ; i < nbscript ; i++) printf "Remote client "i >> outputFile; print "" >> outputFile; } } if ($0 ~ /State name/) { # Table header recognized ! headerRow = 1; stateNb = 0; print "" >> outputFile; print $0 >> outputFile; } # Recopy the graph part which is common to every stat page if ($0 ~ /"cpu_graph"/) footer = 1; if (footer == 1) print $0 >> outputFile; } END { print " Done."; }