source: CIVL/scripts/scale/parseScale.pl@ d402724

1.23 2.0 main test-branch
Last change on this file since d402724 was 04f9ccd, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

minor correction

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2472 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 2.6 KB
Line 
1#!/usr/bin/perl
2use Math::Round;
3use File::Path qw(make_path);
4
5$input_file = $ARGV[0];
6$out_folder = $ARGV[1];
7open(INPUT, "<", $input_file) || die "Could not open $input_file";
8my $outFH;
9my $currentName="";
10my $last=3;
11my $id=0;
12my $tmpDAT="scale.dat.tmp";
13my $dat="scale.dat";
14
15#print "$out_folder\n";
16
17open(my $allFH, '>', $tmpDAT) or die "Can't write to file: $!";
18
19print $allFH "Name\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15";
20
21unless (-d $out_folder) {
22 mkdir $out_folder;
23}
24
25while ($line=<INPUT>) {
26 my($name,$size,$time);
27
28 chomp($line);
29 next unless ($line =~/^>>>>>>>>\s/);
30
31 #print $line . "\n";
32 ($name) = ($line =~/^>>>>>>>>\s(.*)\s<<<<<<<<$/);
33
34 die "no name" unless defined($name);
35 $name =~ tr/ //ds;
36 if($currentName ne $name){
37 $currentName=$name;
38 if(defined($outFH)){
39 close $outFH;
40 }
41 open($outFH, '>', "$out_folder/$name.dat") or die "Can't write to file: $!";
42 $id++;
43 if(($id != 1) and ($last <= 15)){
44 for(my $j = $last; $j <= 15; $j++){
45 print $allFH "\t-";
46 }
47 }
48 #print "name = $name\n";
49 print $allFH "\n$name";
50 $last=3;
51 }
52
53 while ($line=<INPUT>) {
54 chomp($line);
55 if ($line =~ /time\s\(s\).*:/) {
56 #print $line . "\n";
57 ($time)=($line =~ /time.*:\s*(\S+)\s*$/);
58 last;
59 }
60 }
61
62 while ($line=<INPUT>) {
63 chomp($line);
64 if ($line =~ /max\sprocess\scount/) {
65 #print $line . "\n";
66 ($size)=($line =~ /max\sprocess\scount.*:\s*(\d+)\s*$/);
67 last;
68 }
69 }
70
71 die "no size" unless defined($size);
72 die "no time" unless defined($time);
73
74 # $time=round($time); don't round the time
75 $time=1 if $time==0;
76
77 next unless ($size >= $last);
78
79 if($size>$last){
80 #print "size=$size but last=$last\n";
81 for (my $i=$last; $i < $size; $i++) {
82 print $allFH "\t-";
83 }
84 }
85
86 print $allFH "\t$time";
87 print $outFH "$size\t$time\n";
88 $last=$size+1;
89
90 # for debugging:
91
92 #print "size = $size\t";
93 #print "time = $time\n";
94 #print " $type & $name$cite & $result & $loc & $states & $steps & $time & $mem & $valid & $prove & $scale \\\\","\n";
95}
96if(($id != 1) and ($last <= 15)){
97 for(my $j = $last; $j <= 15; $j++){
98 print $allFH "\t-";
99 }
100}
101close $allFH;
102open(my $newFH, '>', $dat) or die "Can't write to file: $!";
103open(DATA, '<', $tmpDAT) or die "Can't open file: $!";
104my $count=0;
105my @lines;
106my $width;
107
108
109while ($line=<DATA>) {
110 chomp($line);
111 @new=split(/\t/, $line);
112 $width=@new;
113 push @lines, [ @new ]; # split = split( ' ', $_ )
114 $count++;
115}
116
117for(my $k=0; $k<$width;$k++){
118 foreach my $row (@lines) {
119 print $newFH $row->[$k] . "\t";
120 }
121 print $newFH "\n";
122}
123close $newFH;
124close DATA;
125unlink $tmpDAT;
126
127
128
Note: See TracBrowser for help on using the repository browser.