this repo has no description
at develop 5.5 kB view raw
1#!/usr/bin/perl 2# 3# Main authors: 4# Christian Schulte <schulte@gecode.org> 5# 6# Copyright: 7# Christian Schulte, 2005 8# 9# This file is part of Gecode, the generic constraint 10# development environment: 11# http://www.gecode.org 12# 13# Permission is hereby granted, free of charge, to any person obtaining 14# a copy of this software and associated documentation files (the 15# "Software"), to deal in the Software without restriction, including 16# without limitation the rights to use, copy, modify, merge, publish, 17# distribute, sublicense, and/or sell copies of the Software, and to 18# permit persons to whom the Software is furnished to do so, subject to 19# the following conditions: 20# 21# The above copyright notice and this permission notice shall be 22# included in all copies or substantial portions of the Software. 23# 24# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31# 32# 33 34@modorder = ("kernel","search","int","set","float","minimodel","gist","driver", 35 "iter","support","example","test","flatzinc"); 36 37@catorder = ("core","memory","var","prop","branch","post", 38 "int","set","float","minimodel","stress","trace","any", 39 "seq","par","search","flatzinc", 40 "other"); 41 42$modclear{"kernel"} = "Kernel"; 43$modclear{"search"} = "Search engines"; 44$modclear{"gist"} = "Gist"; 45$modclear{"int"} = "Integer and Boolean variables and constraints"; 46$modclear{"set"} = "Set variables and constraints"; 47$modclear{"float"} = "Float variables and constraints"; 48$modclear{"minimodel"} = "Minimal modeling support"; 49$modclear{"driver"} = "Script commandline driver"; 50$modclear{"iter"} = "Range and value iterators"; 51$modclear{"support"} = "Support algorithms and datastructures"; 52$modclear{"example"} = "\%Example scripts"; 53$modclear{"test"} = "Systematic tests"; 54$modclear{"flatzinc"} = "FlatZinc interpreter"; 55 56 57$catclear{"core"} = "Core functionality"; 58$catclear{"memory"} = "Memory management"; 59$catclear{"trace"} = "Tracing support"; 60$catclear{"var"} = "Variables, views, and variable implementations"; 61$catclear{"prop"} = "Propagators"; 62$catclear{"branch"} = "Branchers"; 63$catclear{"seq"} = "Sequential search engines"; 64$catclear{"par"} = "Parallel search engines"; 65$catclear{"post"} = "Posting propagators for constraints"; 66$catclear{"any"} = "All"; 67$catclear{"other"} = "Miscellaneous"; 68$catclear{"int"} = "Integer and Boolean variables and constraints"; 69$catclear{"set"} = "Set variables and constraints"; 70$catclear{"float"} = "Float variables and constraints"; 71$catclear{"minimodel"} = "Minimal modeling support"; 72$catclear{"stress"} = "System stress"; 73$catclear{"search"} = "Search"; 74$catclear{"flatzinc"} = "FlatZinc interpreter"; 75$catclear{"ignore"} = "ignored"; 76 77# 78# Get statistics for all files 79# 80 81$i = 0; 82 83while ($file = @ARGV[$i++]) { 84 open(FILE,"<$file"); 85 my $module = "UNKNOWN"; 86 my $cat = "UNKNOWN"; 87 my $n_blank; 88 my $n_comment; 89 my $n_code; 90 my $n_class; 91 while ($l = <FILE>) { 92 if ($l =~ /\/\/ STATISTICS: ([A-Za-z]+)-([A-Za-z]+)/) { 93 $module = $1; 94 $cat = $2; 95 exists $modclear{$module} or die "Module $m undefined (file $file)"; 96 exists $catclear{$cat} or die "Category $cat undefined (file $file)"; 97 } 98 if ($l =~ /^[ \t]*$/) { 99 $n_blank += 1; 100 } elsif ($l =~ /^[ \t]*\/\//) { 101 $n_comment += 1; 102 } elsif ($l =~ /\/\*/) { 103 $n_comment += 1; 104 while (!($l =~ /\*\//) && ($l = <FILE>)) { 105 $n_comment += 1; 106 } 107 } else { 108 $n_code += 1; 109 } 110 if ($l =~ /class [A-Za-z_][A-Za-z0-9_]*.*\{/) { 111 $n_class += 1; 112 } 113 } 114 if ($module eq "UNKNOWN") { 115 print "UNKNOWN: $file\n"; 116 exit 1; 117 } 118 $m{$module} = 1; 119 $c{$cat} = 1; 120 $class{"$module-$cat"} += $n_class; 121 $comment{"$module-$cat"} += $n_comment; 122 $blank{"$module-$cat"} += $n_blank; 123 $code{"$module-$cat"} += $n_code; 124 close FILE; 125} 126 127$i = 0; 128 129print <<EOF 130/** 131 \\page PageCodeStat Gecode code statistics 132 133The following approximate breakdown into the different parts of %Gecode 134gives some statistics about the amount of code and documentation 135contained in the code (as comments) where blank lines are excluded. 136 137The abbreviation "loc" means "lines of code" and "lod" means "lines of 138documentation". 139 140EOF 141; 142 143 144$an_code = 0; 145$an_comment = 0; 146$an_class = 0; 147 148foreach $module (@modorder) { 149 print " - " . $modclear{$module} . ": "; 150 $mn_code = 0; 151 $mn_comment = 0; 152 $mn_class = 0; 153 $n_cat = 0; 154 $doc = ""; 155 foreach $cat (@catorder) { 156 $k = "$module-$cat"; 157 if ($code{$k}) { 158 $n_cat += 1; 159 $doc = $doc . " - " . $catclear{$cat} . ": "; 160 $mn_code += $code{$k}; 161 $mn_comment += $comment{$k}; 162 $mn_class += $class{$k}; 163 $doc = $doc . $class{$k} . " classes, "; 164 $doc = $doc . $code{$k} . " loc, "; 165 $doc = $doc . $comment{$k} . " lod\n"; 166 } 167 } 168 print $mn_class . " classes, " . $mn_code . " loc, " . $mn_comment . " lod\n"; 169 if ($n_cat > 1) { 170 print $doc; 171 } 172 $an_code += $mn_code; 173 $an_comment += $mn_comment; 174 $an_class += $mn_class; 175} 176 177 178print <<EOF 179 180The grand total: $an_class classes, $an_code loc, $an_comment lod 181 182*/ 183EOF 184; 185