#!/bin/sh type="$1" shift awk ' { if ($1 == "machinespeed") { nummachines = nummachines + 1 machinebynumber[nummachines] = $2 } else if ($1 == "machine") { gsub(/-.*/,"",$3) machinedesc[$2] = $2"\\n"$3 gsub(/~/," ",machinedesc[$2]) } else if ($1 == "machinedesc") { for (j = 3;j <= NF;++j) machinedesc[$2] = machinedesc[$2]"\\n"$j gsub(/~/," ",machinedesc[$2]) } else if ($1 == "cipherspeed") { numciphers = numciphers + 1 cipherbynumber[numciphers] = $2 } else if ($1 == "cipher") { cipherabbrev[$2] = $3 cipherdesc[$2] = $4 x = $2 sub(/\..*/,"",x) for (j = 5;j <= NF;++j) cipherdesc[$2] = cipherdesc[$2]" "$j cipherdesc[$2] = cipherdesc[$2]" "x" ("$3")" } else if ($1 == "'$type'") { cyclesperbyte[$2" "$3] = $4 } } END { width = 100 + 100 * nummachines if (width < 1536) width = 1536 height = 1536 width = width * 2 height = height * 2 print "set term png font '\''freefont/FreeSansBold'\'' 25 size "width","height print "set pointsize 2" print "set xtics (\\" for (i = 1;i <= nummachines;++i) { if (i > 1) print ",\\" print "\"" machinedesc[machinebynumber[i]] "\" "i"\\" } print ")" print "set bmargin 15" print "set rmargin 5" print "set logscale y" print "set ytics 2" print "set mytics 0" print "set grid xtics" print "set grid ytics" print "set key below" if (nummachines < 10) print "set xrange [1:10]" else print "set xrange [1:"(nummachines+0)"]" bottom = 1.5 top = 384 print "set yrange ["bottom":"top"]" print "set offsets 0.5, 0.5" for (j = 1;j <= nummachines;++j) { h = bottom for (;;) { mincyclesperbyte = top * 2 for (i = 1;i <= numciphers;++i) if (cipherbynumber[i] in cipherdesc) if ((machinebynumber[j]" "cipherbynumber[i] in cyclesperbyte)) if (!(machinebynumber[j]" "cipherbynumber[i] in labelheight)) if (cyclesperbyte[machinebynumber[j]" "cipherbynumber[i]] < mincyclesperbyte) mincyclesperbyte = cyclesperbyte[machinebynumber[j]" "cipherbynumber[i]] for (i = 1;i <= numciphers;++i) if (cipherbynumber[i] in cipherdesc) if ((machinebynumber[j]" "cipherbynumber[i] in cyclesperbyte)) if (!(machinebynumber[j]" "cipherbynumber[i] in labelheight)) if (cyclesperbyte[machinebynumber[j]" "cipherbynumber[i]] == mincyclesperbyte) break if (i > numciphers) break if (mincyclesperbyte < h * 1.06) mincyclesperbyte = h * 1.06 h = mincyclesperbyte labelheight[machinebynumber[j]" "cipherbynumber[i]] = h } } for (i = 1;i <= numciphers;++i) if (cipherbynumber[i] in cipherdesc) for (j = 1;j <= nummachines;++j) if ((machinebynumber[j]" "cipherbynumber[i]) in cyclesperbyte) { x = cyclesperbyte[machinebynumber[j]" "cipherbynumber[i]] if (x < top) { x = labelheight[machinebynumber[j]" "cipherbynumber[i]] if (j <= nummachines / 2) { print "set label \""cipherabbrev[cipherbynumber[i]]" \" at "j","x" right font \"freefont/FreeSansBold,20\"" } else { print "set label \" "cipherabbrev[cipherbynumber[i]]"\" at "j","x" left font \"freefont/FreeSansBold,20\"" } } } print "set title \"'"$*"'\"" print "set format \"%.0f\"" print "plot \\" first = 1 for (i = 1;i <= numciphers;++i) if (cipherbynumber[i] in cipherdesc) { if (!first) print ", \\" first = 0 print "'\''-'\'' title '\''"cipherdesc[cipherbynumber[i]]"'\'' with linespoints pointtype 6 linewidth 6 \\" } print "" for (i = 1;i <= numciphers;++i) if (cipherbynumber[i] in cipherdesc) { for (j = 1;j <= nummachines;++j) if (machinebynumber[j]" "cipherbynumber[i] in cyclesperbyte) print j,cyclesperbyte[machinebynumber[j]" "cipherbynumber[i]] print "e" } } ' > .graphtmp.plot awk '/^[0-9]/ { print $1,"-999"; next } { print }' < .graphtmp.plot \ | gnuplot \ | pngtopnm \ > .graphtmp.top ppmtopgm < .graphtmp.top > .graphtmp.mask gnuplot < .graphtmp.plot \ | pngtopnm \ | pnmcomp -invert -alpha=.graphtmp.mask .graphtmp.top \ | pnmscale 0.5 \ | pnmtopng rm .graphtmp.plot rm .graphtmp.top rm .graphtmp.mask