File: getctx

package info (click to toggle)
lmbench 3.0-a9%2Bdebian.1-6
  • links: PTS
  • area: non-free
  • in suites: bookworm
  • size: 2,996 kB
  • sloc: ansic: 12,328; perl: 6,531; sh: 2,784; makefile: 731
file content (79 lines) | stat: -rwxr-xr-x 1,605 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

# Extract the context switching information from lmbench result files.
# Usage: getctx file file....
#
# Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
# Copyright (c) 1994 Larry McVoy.  GPLed software.
# $Id$
eval 'exec perl -Ss $0 "$@"'
	if 0;

$title = "foo" if 0;

foreach $file (@ARGV) {
	open(FD, $file);
	while (<FD>) {
		chop;
		if (/^\[lmbench/) {
			@_ = split;
			if ($_[3] eq "SunOS") {
				$_[3] .= "-$_[5]";
			}
			$uname = "@_";
		}
		if (/Mhz/) {
			$mhz = $_;
		}
		if (/^.size=/) {
			s/size/Process size/;
			s/ ovr/\toverhead/;
			@info = &getinfo($uname, $mhz);
			($f = $file) =~ s|/|-|;
			print "tmp/ctx.$f\n";
			open(OUT, ">tmp/ctx.$f");
			print OUT "\"%X Processes \n\"%Y Time in microseconds\n";
			if ($title) {
				print OUT "%T $f\n";
			} else {
				print OUT
				    "\"%T Context switches for " . 
				    "$info[3] $info[$#info]Mhz\n";
			}
			print OUT "$_\n";
			while (<FD>) {
				last if /^Null/ || /^Pipe/ || /^Memor/ || /^tlb:/;
				next if /\$Id/;
				next if m|scripts/lmbench: /dev/tty|;
				s/ ovr/\toverhead/;
				s/size/Process size/;
			    	print OUT;
			}
			close(OUT);
			last;
		}
	}
}

# Try and create sensible names from uname -a output
sub getinfo
{
	local(@info);
	local($name);
	local($mhz);

	($mhz = $_[1]) =~ s/[\. ].*//;
	@info = split(/\s+/, $_[0]);
	$name = pop(@info);
	chop($name);
	if ($name eq "mips") {
		$name = "$info[$#info]@$mhz";
	} elsif ($_[0] =~ /HP-UX/) {
		$name = "$info[7]@$mhz";
	} elsif ($_[0] =~ /SunOS/) {
		$name = "$info[7]@$mhz";
	} else {
		$name .= "@$mhz";
	}
	push(@info, $name);
	@info;
}