#!/bin/bash

rm -rf res; mkdir res

tst() {
   res=$((res + 1))
   echo
   echo res/$res
   PERL_ANYEVENT_MODEL=$1 perl $4 bench $2 "$3" $1/$3 | tee res/$res
}

export PERL_ANYEVENT_VERBOSE=1

tst EV 50000 EV
tst EV 50000 Any
tst CoroEV 50000 Any
tst Perl 50000 Any
tst Event 8000 Event
tst Event 8000 Any
tst Glib 8000 Any
tst Tk 1000 Any
tst POE 1000 Any "-MEvent -MPOE=Loop::Event"
tst POE 1000 Any "-MPOE=Loop::Select"

echo
echo
echo
echo

for ((i=2;i<=res;++i)); do
   join res/1 res/$i >res/x && mv res/x res/1
done

{
   <res/1 perl -e '
      print "
";
      push @a, [split /\s+/] while <>;
      for my $x (0 .. $#{$a[0]}) {
         print "";
         for my $y (0 .. $#a) {
            print " ", $a[$y][$x], "";
         }
         print "
";
      }
      print "
";
   '
} >res/1.html
links -dump res/1.html
