[Swift-commit] r7527 - SwiftApps/heap-plot
davidk at ci.uchicago.edu
davidk at ci.uchicago.edu
Wed Jan 29 19:14:51 CST 2014
Author: davidk
Date: 2014-01-29 19:14:51 -0600 (Wed, 29 Jan 2014)
New Revision: 7527
Added:
SwiftApps/heap-plot/heap-plot.pl
Log:
heap-plot.pl
Added: SwiftApps/heap-plot/heap-plot.pl
===================================================================
--- SwiftApps/heap-plot/heap-plot.pl (rev 0)
+++ SwiftApps/heap-plot/heap-plot.pl 2014-01-30 01:14:51 UTC (rev 7527)
@@ -0,0 +1,87 @@
+#!/usr/bin/perl -w
+use strict;
+use Time::Local;
+
+# Usage: ./heapplot.pl run000.log
+my $first_timestamp=0;
+
+# Read file
+my $filename=shift;
+open(FILE, "$filename") || die "Unable to open $filename\n";
+my @filedata = <FILE>;
+close(FILE);
+
+# Open file for writing
+open(FILE, ">heap-plot.dat") || die "Unable to open activityplot.dat for writing\n";
+print FILE "Time Max Crt Used\n";
+
+sub get_value
+{
+ my $statement = $_[0];
+ my $value = (split /:/, $statement)[1];
+ chop($value);
+ return $value;
+}
+
+sub timestamp_to_seconds
+{
+ (my $date, my $hhmmss, my @junk) = split('\s+', $_[0]);
+ $hhmmss = (split /,/, $hhmmss)[0];
+ (my $year, my $month, my $monthday) = split('\-', $date);
+ (my $hh, my $mm, my $ss) = split(':', $hhmmss);
+ my $time = timelocal($ss, $mm, $hh, $monthday-1, $month, $year);
+ return $time;
+}
+
+foreach my $line(@filedata) {
+ if( $line =~ m/HeapMax/ ) {
+ $line =~ s/HeapMax: /HeapMax:/g;
+ $line =~ s/CrtHeap: /CrtHeap:/g;
+ $line =~ s/UsedHeap: /UsedHeap:/g;
+ my @words = split('\s+', $line);
+ my $timestamp = timestamp_to_seconds($line);
+
+ if($first_timestamp == 0) { $first_timestamp = $timestamp; $timestamp=0; }
+ else { $timestamp = $timestamp - $first_timestamp; }
+
+ my $max = 0;
+ my $crt = 0;
+ my $used = 0;
+ my $active = 0;
+
+ foreach my $word(@words) {
+ if($word =~ /HeapMax:/) { $max = get_value($word); }
+ elsif($word =~ /CrtHeap:/) { $crt = get_value($word); }
+ elsif($word =~ /UsedHeap:/) { $used = get_value($word); }
+ # elsif($word =~ /Active:/) { $active = get_value($word); }
+ }
+
+ # Adjust values for plotting
+ print FILE "$timestamp $max $crt $used\n";
+ }
+}
+
+close(FILE);
+open(FILE, ">heap-plot.gp") || die "Unable to create heap-plot.gp";
+
+my $gp = <<END;
+set key autotitle columnhead
+set terminal png size 1000,1000 enhanced
+set title "Heap Plot"
+set output "heap-plot.png"
+
+set xlabel "Time in sec"
+set ylabel "Size in MB"
+set autoscale x
+
+plot "heap-plot.dat" using 0:(\$2/1048576) with lines, \\
+ '' using 0:(\$3/1048576) with lines, \\
+ '' using 0:(\$4/1048576) with lines
+END
+
+print FILE $gp;
+close(FILE);
+
+system("gnuplot heap-plot.gp");
+unlink("heap-plot.gp");
+unlink("heap-plot.dat");
Property changes on: SwiftApps/heap-plot/heap-plot.pl
___________________________________________________________________
Added: svn:executable
+ *
More information about the Swift-commit
mailing list