File: perlhist_calculate.pl

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (165 lines) | stat: -rwxr-xr-x 2,701 bytes parent folder | download | duplicates (3)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!perl
# Generates info for perlhist from this perl tree
# run this from the root of a perl tree
#
# Data is on STDOUT.

use 5.010000;
use File::Find;
use warnings;
use strict;

sub emit {
  my $H = '%-9s:';
  my $D = '%6d';
  printf "$H $D $D\n", @_;
}

sub calc_core {

	my @core;
	push @core, glob '*.h';
	push @core, glob '*.c';
	push @core, glob '*.y';
	my $coresize = 0;

	foreach my $corefile (@core) {
		$coresize += (-s $corefile) / 1000;
	}

	my $corenumber = scalar @core;
	$coresize = int $coresize;

  return $coresize, $corenumber;
}

sub calc_lib {

	our $libsize = 0;
	our $libnumber = 0;
	sub wanted_lib {
		$File::Find::name =~ /[.] (?:pm|pl)\z/msx or return;
		$libsize += (-s $_) / 1000;
		$libnumber++;
	}

	find(\&wanted_lib, 'lib');
	$libsize = int $libsize;

  return $libsize, $libnumber;
}

sub calc_ext {

	our $extsize = 0;
	our $extnumber = 0;
	sub wanted_ext {
		$File::Find::name =~ /[.] (?:h|c|y|t|xs|pm)\z/msx or return;
		$extsize += (-s $_) / 1000;
		$extnumber++;
	}

	if (-d 'dist') {
		find(\&wanted_ext, 'ext', 'dist', 'cpan');
	} else {
		find(\&wanted_ext, 'ext');
	}

	$extsize = int $extsize;

  return $extsize, $extnumber;
}

sub calc_t {

	our $tsize = 0;
	our $tnumber = 0;
	sub wanted_t {
		$File::Find::name =~ /[.] t\z/msx or return;
		$tsize += (-s $_) / 1000;
		$tnumber++;
	}

	find(\&wanted_t, '.');

	$tsize = int $tsize;

  return $tsize, $tnumber;
}

sub calc_doc {

	my @doc;
	push @doc, 'INSTALL';
	push @doc, 'README';
	push @doc, glob 'README.*';
	our $docsize = 0;

	foreach my $docfile (@doc) {
		$docsize += (-s $docfile) / 1000;
	}

	our $docnumber = scalar @doc;

	sub wanted_doc {
		$File::Find::name =~ /[.] pod\z/msx or return;
		$docsize += (-s $_) / 1000;
		$docnumber++;
	}

	find(\&wanted_doc, 'pod');

	$docsize = int $docsize;

  return $docsize, $docnumber;
}

sub calc_dir {
	my $dir = shift;

	return if ! -d $dir;

	our $dirnumber = 0;
	our $dirsize = 0;

	sub wanted_dir {
		$dirsize += (-s $_) / 1000;
		$dirnumber++;
	}

	find(\&wanted_dir, $dir);

	$dirsize = int $dirsize;

  emit $dir => $dirsize, $dirnumber;
}


sub calc_longtable {

	print "\n\nTable:\n";

	my $configure_size = int ((-s 'Configure') / 1000);

	emit Configure => $configure_size, 1;

	foreach my $dir (qw(Cross djgpp emacs h2pl hints NetWare os2 plan9 Porting qnx symbian utils vms vos win32)) {
		calc_dir($dir);
	}
}

say "Selected release sizes for perl tarball:";
print "\n";

 #5.16.0         5562 109   1077  80  20504 2702   8750 2375   4815 152

sub calc_line {
  printf " %-12s %6s %3s %6s %3s %6s %4s %6s %4s %6s %3s\n",
    '5.xx.0', calc_core(), calc_lib(), calc_ext(), calc_t(), calc_doc();
}

calc_line();

calc_longtable();

exit;