-
Notifications
You must be signed in to change notification settings - Fork 1
/
bon_csv2txt
98 lines (88 loc) · 2.62 KB
/
bon_csv2txt
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl
{
my $line;
$iocount = 0;
$filecount = 0;
while($line = <STDIN>)
{
while($line =~ /^name,/)
{
$line = <STDIN>;
}
process($line);
}
printIOData();
printFileData();
}
sub IOHeader
{
my $version = '1.04';
print "Version $version ------Sequential Output------ --Sequential Input- --Random-\n";
print " -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--\n";
print "Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP\n";
}
sub FileHeader
{
print " ------Sequential Create------ --------Random Create--------\n";
print " -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--\n";
print "files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP\n";
}
sub process
{
my($line) = @_;
chop($line);
my $name = $line;
$name =~ s/,.*$//;
$line =~ s/$name,//;
# $ioline contains the file-IO data, IE we strip off the data on file creation
my $ioline = $line;
$ioline =~ s/,[:0-9\-\+.\/]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+,[0-9\+.]+$//;
$ioline =~ s/,,,,,,,,,,,,,$//;
if(join('', split(/,/,$ioline)) != "")
{
$io[$iocount] = $name . "," . $ioline;
$iocount++;
}
# $fileline contains the file creation data - everything but $ioline
my $fileline = substr($line, length($ioline));
if(join('', split(/,/,$fileline)) != "")
{
$file[$filecount] = $name . $fileline;
$filecount++;
}
}
sub printFileData
{
if($filecount < 1){ return; }
FileHeader();
for($i = 0; $i < $filecount; $i++)
{
@arr = split(/,/,$file[$i]);
my $size = $arr[1];
$size =~ s/:0:0:/\//;
my $desc = $arr[0] . " ";
$desc = substr($desc, 0, 18 - length($size) );
$desc .= " " . $size;
printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
, $desc, $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]
, $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13]
, $arr[14], $arr[15]);
}
}
sub printIOData
{
if($iocount < 1){ return; }
IOHeader();
for($i = 0; $i < $iocount; $i++)
{
@arr = split(/,/,$io[$i]);
my $size = $arr[1];
my $desc = $arr[0] . " ";
$desc = substr($desc, 0, 18 - length($size) );
$desc .= " " . $size;
printf(STDOUT "%19s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s %5s %3s\n"
, $desc, $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7]
, $arr[8], $arr[9], $arr[10], $arr[11], $arr[12], $arr[13]
, $arr[14], $arr[15]);
}
}