#! /usr/bin/perl -w # We have four data sets, each consisting of N lines which read # , in the order: read/nopurge, mmap/nopurge, # read/purge, mmap/purge. Each block is separated by two blank lines. # # We want to subtract the nopurge times from the purge times, isolating # the time (user and system) spent in read or mmap. (Which should include # delays due to worse cache utilization. sub max { return $_[0] > $_[1] ? $_[0] : $_[1]; } @read_nopurge = (); @mmap_nopurge = (); @read_purge = (); @mmap_purge = (); for $vec (\@read_nopurge, \@mmap_nopurge, \@read_purge, \@mmap_purge) { while (<>) { last if /^$/; push @$vec, $_; } die "mangled input" unless eof() || ($_ = <>) =~ /^$/; } die "vectors not all equal" unless $#read_nopurge == $#mmap_nopurge && $#mmap_nopurge == $#read_purge && $#read_purge == $#mmap_purge; for ($i = 0; $i <= $#read_nopurge; $i++) { @A = split(/ /, $read_nopurge[$i]); @B = split(/ /, $read_purge[$i]); die "mismatched sizes, index $i\n" unless $A[0] == $B[0]; die "wrong number of fields, index $i\n" unless $#A == 2 && $#B == 2; printf("%.1f %.2f %.2f\n", $A[0] / 1024, max($B[1] - $A[1], 0), max($B[2] - $A[2], 0)); } print "\n\n"; for ($i = 0; $i <= $#mmap_nopurge; $i++) { @A = split(/ /, $mmap_nopurge[$i]); @B = split(/ /, $mmap_purge[$i]); die "mismatched sizes, index $i\n" unless $A[0] == $B[0]; die "wrong number of fields, index $i\n" unless $#A == 2 && $#B == 2; printf("%.1f %.2f %.2f\n", $A[0] / 1024, max($B[1] - $A[1], 0), max($B[2] - $A[2], 0)); }