#!/usr/local/bin/perl

%ss = ();
$i = 0;
$laststate = 0;
$lasttime = 0;

while (<>) {
  #looking for
  #  event fired - I am (c,1.01).(d,4.0).A after 0.31088995678694653
  if (/ event fired - I am (.+) after (.+)/) {
    $i++;
    #$laststate = $1;
    $lasttime = $2;
    $done = 0;
    $l = <>;
    while (! ($l =~ / the simderiv will be (.+)$/ )) {
      $l = <>;
    }
    $_ = $l;
    / the simderiv will be (.+)$/;
    #print "l is $l\n";
    #print "1 is $1\n";
    #print "laststate is $laststate\n";
    #print "lasttimeis $lasttime\n";
    if ($laststate) {
      $ss{$laststate} += $lasttime; # - $lasttime;
    }
    # the simderiv printed is the next one we go to!!!!
    $laststate = $1;
    #print $laststate." is the laststate\n";
    #print $lasttime." is the lasttime\n";
    if (($i % 10) == 0) {
    #if (1) {
      $ttime = 0;
      while (@ssi = each %ss) {
	$ttime += $ssi[1];
      }
      print "stats:\n";
      print "*simulation time $ttime\n";
      while (@ssi = each %ss) {
	print $ssi[0];
	print " time ";
	print $ssi[1];
	print "\n";
      }
    }
  }
}

    
  
