Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[a79fd6]: bin / extractmmtkstats Maximize Restore History

Download this file

extractmmtkstats    62 lines (52 with data), 1.6 kB

#!/usr/bin/perl
#
#  This file is part of the Jikes RVM project (http://jikesrvm.org).
#
#  This file is licensed to You under the Eclipse Public License (EPL);
#  You may not use this file except in compliance with the License. You
#  may obtain a copy of the License at
#
#      http://www.opensource.org/licenses/eclipse-1.0.php
#
#  See the COPYRIGHT.txt file distributed with this work for information
#  regarding copyright ownership.
#

# The input file
$infile = shift(@ARGV);

# The output file to append to
$outfile = shift(@ARGV);

# The pattern for the output. @VALUE@ and @STATISTIC@ are replaced
$outpattern = "<statistic key=\"\@STATISTIC\@\" value=\"\@VALUE\@\"/>";

# The keys to extract
@queryKeys = @ARGV;

open ($LOG, "$infile") or die "error opening $infile for input";
open ($OUT, ">>$outfile") or die "error opening $outfile for output";

while (<$LOG>) {
  if (/^============================ MMTk Statistics Totals ============================/) {
    $headerline = (<$LOG>);
    $dataline = (<$LOG>);
  }
}
close($LOG);

$headerline =~ /^GC/ or die "could not find headers";
@keys = split("\t", $headerline);
@values = split("\t", $dataline);

$#keys == $#values or die "headers and values do not match"; 

foreach $q (@queryKeys) {
  $keyid = 0;
  foreach $k (@keys) {
    chomp($k);
    if ($k ne "") {
      if ($k eq $q) {
        $result{$q} = 1;
        $output = $outpattern;
        $output =~ s/\@STATISTIC\@/$k/;
        $output =~ s/\@VALUE\@/$values[$keyid]/;
        print $OUT $output;
      }
    }
    $keyid++;
  }
  $result{$q} or die "could not extract $q";
}
close($OUT);