1
2# Extract the memory latency graph data from lmbench result files.
3#
4# Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
5# Copyright (c) 1994 Larry McVoy.  GPLed software.
6# $Id$
7eval 'exec perl -Ss $0 "$@"'
8	if 0;
9
10foreach $file (@ARGV) {
11	open(FD, $file);
12	$file =~ s|/|-|;
13	while (<FD>) {
14		chop;
15		next if m|scripts/lmbench: /dev/tty|;
16		if (/^\[lmbench/) {
17			@_ = split;
18			if ($_[3] eq "SunOS") {
19				$_[3] .= "-$_[5]";
20			}
21			$uname = "@_";
22		}
23		if (/Mhz/) {
24			$mhz = $_;
25		}
26		if (/^Memory load latency/) {
27			@info = &getinfo($uname, $mhz);
28			($f = $file) =~ s|.*/||;
29			print "tmp/mem.$f\n";
30			open(OUT, ">tmp/mem.$f");
31			print OUT "\"%X Array size\n\"%Y Latency in nanoseconds\n";
32			print OUT
33			    "\"%T $file $info[3] $info[$#info] memory latencies\n";
34			while (<FD>) {
35				next if /\$Id/;
36				next if /^\[/;
37				last if /^Random load latency/;
38			    	print OUT;
39			}
40			close(OUT);
41			last;
42		}
43	}
44}
45exit 0;
46
47# Try and create sensible names from uname -a output
48sub getinfo
49{
50	local(@info);
51	local($name);
52	local($mhz) = $_[1];
53
54	$mhz =~ s/\..*//;
55	$mhz =~ s/ .*//;
56	@info = split(/\s+/, $_[0]);
57	$name = pop(@info);
58	chop($name);
59	if ($name eq "mips") {
60		$name = "$info[$#info]@$mhz";
61	} elsif ($_[0] =~ /HP-UX/) {
62		$name = "$info[7]@$mhz";
63	} elsif ($_[0] =~ /SunOS/) {
64		$name = "$info[7]@$mhz";
65	} else {
66		$name .= "@$mhz";
67	}
68	push(@info, $name);
69	@info;
70}
71