#!/usr/local/bin/perl -w # merge_hi.p # merges histogram files from same x runs sub bynumber { $a <=> $b; } $Loops = 2000 ; @percentiles = (0.05 , 0.25 , 0.50 , 0.75 , 0.95, 100) ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $actualLoops = 0 ; $line = 0 ; for ( $n = 1 ; $n <= $Loops ; $n ++ ) { $c[$n] = 0 ; } $tot = 0 ; $secondtot = 0 ; while (<>) { if ( /^\# total valid blocks ([^\s]+)/ ) { $thistot = $1 ; $tot += $thistot ; } if ($_ ne "\n" && !(/^\#/)) { $line ++ ; s/^\s+// ; ($n,$count,$cum,$rest) = split(' ',$_); $c[$n] += $count ; $secondtot += $count ; if ( $n > $actualLoops ) { $actualLoops = $n ; } } } $shutup = $rest ; $rest = $shutup ; # hack to suppress error message if ( !$line ) { print "# No data found by merge_hi.p \n" ; exit(0) ; } if ( !($secondtot == $tot) ) { print STDERR "unequal $secondtot == $tot\n" ; } $Loops = $actualLoops ; $pile = 0 ; # which percentile we are looking for $pstring = "# Percentiles\n# ".join("\t",@percentiles)."\n# " ; $cum = 0.0 ; $hstring = sprintf ( "# total valid blocks %d\n" , $tot ) ; for ( $l = 1 ; $l <= $Loops ; $l ++ ) { $t = $c[$l] ; $cum += $t ; $f = $cum/$tot ; $hstring .= sprintf "%d\t%d\t%d\t%9.4g\t%9.4g\n" , $l , ($t) , ($cum) , $t/$tot , $f ; if ( $f >= $percentiles[$pile] ) { # $pstring .= "$l ($f>$percentiles[$pile])\t" ; $pstring .= "$l\t" ; $pile ++ ; } } $pstring .= "\n" ; print $pstring , $hstring ;