@@ -31,81 +31,106 @@ unit class Statisfiable does Whateverable;
31
31
constant RANGE = ‘ 2014.01..HEAD’ ;
32
32
constant STATS-LOCATION = ‘ ./stats’ . IO . absolute;
33
33
34
+ constant OPTIONS = % (
35
+ core => ‘ CORE.setting.moarvm file size (MB)’ ,
36
+ # ‘core.lines’ => ‘Lines in CORE.setting.moarvm file (count)’,
37
+ install => ‘ Space taken by a full installation (MB)’ ,
38
+ libmoar => ‘ libmoar.so file size (MB)’ ,
39
+ );
40
+
34
41
has % stats ;
42
+ has % stat-locks ;
35
43
36
44
method TWEAK {
37
45
mkdir STATS-LOCATION if STATS-LOCATION. IO ! ~~ : d;
38
- if “ { STATS-LOCATION } / ” {
39
- % stats < core > = from-json slurp “ { STATS-LOCATION } /core ” if “ { STATS-LOCATION } /core ” . IO . e ;
40
- % stats < core > // = % ();
41
- % stats < install > = from-json slurp “ { STATS-LOCATION} /install ” if “ { STATS-LOCATION } /install ” . IO . e ;
42
- % stats < install > // = % ()
46
+ for OPTIONS . keys {
47
+ % stat-locks { $ _ } = Lock . new ;
48
+ % stats { $ _ } = “ { STATS-LOCATION } / $ _ ” . IO . e
49
+ ⁇ from-json slurp “ { STATS-LOCATION} /$ _ ”
50
+ ‼ % ()
43
51
}
44
52
}
45
53
46
54
method help ($) {
47
- ‘ Available stats: core (CORE.setting size), install (size of the whole installation).’
55
+ ‘ Available stats: ’ ~ (
56
+ ‘ core (CORE.setting size)’ ,
57
+ # ‘core.lines (lines in CORE.setting)’,
58
+ ‘ install (size of the installation)’ ,
59
+ ‘ libmoar (libmoar.so size)’ ,
60
+ ). join : ‘ , ’
48
61
}
49
62
50
- multi method irc-to-me ($ msg where /: i [ core | install ] / ) {
51
- my ($ value , % additional-files ) = self . process: $ msg , $ msg . text;
52
- return without $ value ;
53
- return ($ value but $ msg ) but FileStore(% additional-files )
63
+ multi method stat-for-commit (‘ core’ , $ full-hash ) {
64
+ self . run-smth: $ full-hash , {
65
+ my $ file = “ $ _ /share/perl6/runtime/CORE.setting.moarvm” . IO ;
66
+ $ file . IO . e ⁇ $ file . IO . s ÷ 10 ⁶ ‼ Nil
67
+ }
54
68
}
55
69
56
- multi method process ($ msg , $ query ) {
57
- $ msg . reply: ‘ OK! Working on it…’ ;
70
+ # multi method stat-for-commit(‘core.lines’, $full-hash) {
71
+ # # TODO
72
+ # }
73
+
74
+ multi method stat-for-commit (‘ install’ , $ full-hash ) {
75
+ self . run-smth: $ full-hash , {
76
+ # ↓ scary, but works
77
+ my $ result = Rakudo::Internals. DIR-RECURSE($ _ ). map (*. IO . s ). sum ÷ 10 ⁶;
78
+ $ result > 10 ⁇ $ result ‼ Nil
79
+ }
80
+ }
81
+
82
+ multi method stat-for-commit (‘ libmoar’ , $ full-hash ) {
83
+ self . run-smth: $ full-hash , {
84
+ my $ file = “ $ _ /lib/libmoar.so” . IO ;
85
+ $ file . IO . e ⁇ $ file . IO . s ÷ 10 ⁶ ‼ Nil
86
+ }
87
+ }
58
88
59
- my $ type = $ query ~~ /:i core / ⁇ ‘ core’ ‼ ‘ install’ ;
60
- my $ zero = $ query ~~ / 0 / ⁇ 0 ‼ Nil ;
61
- my % data := % stats {$ type };
89
+ multi method irc-to-me ($ msg where /: i ( <{OPTIONS.keys} > ) (‘ 0’ )? / ) {
90
+ my $ type = ~ $0 ;
91
+ my $ zeroed = ? $1 ;
92
+ start {
93
+ my ($ value , % additional-files ) = self . process: $ msg , $ type , $ zeroed ;
94
+ $ value . defined
95
+ ⁇ ($ value but $ msg ) but FileStore(% additional-files )
96
+ ‼ Nil
97
+ }
98
+ }
62
99
63
- my @ git = ‘ git ’ , ‘ --git-dir ’ , “ { RAKUDO } /.git ” , ‘ --work-tree ’ , RAKUDO;
64
- my @ command = | @ git , ‘ log ’ , ‘ -z ’ , ‘ --pretty=%H ’ , RANGE ;
100
+ multi method process ( $ msg , $ type , $ zeroed ) {
101
+ $ msg . reply : ‘ OK! Working on it… ’ ;
65
102
66
- my $ let's-save = False ;
67
103
my @ results ;
68
- for run (: out, | @ command ). out. split : 0 . chr , : skip-empty {
69
- next unless $ _ ;
70
- my $ full = $ _ ;
71
- # my $short = self.to-full-commit($_, :short);
72
-
73
- my $ size ;
74
- if % data {$ full }: exists {
75
- $ size = % data {$ full }
76
- } else {
77
- if self . build-exists: $ full {
78
- if $ type eq ‘ core’ { # core
79
- $ size = self . run-smth: $ full , {
80
- my $ file = “ $ _ /share/perl6/runtime/CORE.setting.moarvm” . IO ;
81
- $ file . IO . e ⁇ $ file . IO . s ÷ 10 ⁶ ‼ Nil
82
- }
83
- } else { # install
84
- $ size = self . run-smth: $ full , {
85
- # ↓ scary, but works
86
- Rakudo::Internals. DIR-RECURSE($ _ ). map (*. IO . s ). sum ÷ 10 ⁶
87
- }
88
- }
104
+ % stat-locks {$ type }. protect: {
105
+ my % data := % stats {$ type };
106
+
107
+ my $ let's-save = False ;
108
+
109
+ my @ git = ‘ git’ , ‘ --git-dir’ , “ { RAKUDO} /.git” , ‘ --work-tree’ , RAKUDO;
110
+ my @ command = | @ git , ‘ log’ , ‘ -z’ , ‘ --pretty=%H’ , RANGE;
111
+ for run (: out, | @ command ). out. split : 0 . chr , : skip-empty -> $ full {
112
+ next unless $ full ;
113
+ # my $short = self.to-full-commit($_, :short);
114
+
115
+ if % data {$ full }:! exists and self . build-exists: $ full {
116
+ % data {$ full } = self . stat-for-commit($ type , $ full );
117
+ $ let's-save = True
89
118
}
90
- % data {$ full } = $ size ;
91
- $ let's-save = True
119
+ @ results . push : ($ full , $ _ ) with % data {$ full }
92
120
}
93
- @ results . push : ($ full , $ size ) if $ size and ($ type eq ‘ core’ or $ size > 10 )
94
- }
95
-
96
- spurt “ { STATS-LOCATION} /$ type” , to-json % data if $ let's-save ;
97
121
122
+ spurt “ { STATS-LOCATION} /$ type” , to-json % data if $ let's-save ;
123
+ }
98
124
99
125
my $ pfilename = ‘ plot.svg’ ;
100
- my $ title = $ type eq ‘ core’ ⁇ ‘ CORE.setting.moarvm file size (MB)’
101
- ‼ ‘ Installation size (MB)’ ;
126
+ my $ title = OPTIONS{$ type };
102
127
my @ values = @ results . reverse »[1 ];
103
128
my @ labels = @ results . reverse »[0 ]». substr : 0 , 8 ;
104
129
105
130
my $ plot = SVG::Plot. new (
106
- width => 1000 ,
107
- height => 800 ,
108
- min-y-axis => $ zero ,
131
+ : 1000 width ,
132
+ : 800 height ,
133
+ min-y-axis => $ zeroed ⁇ 0 ‼ Nil ,
109
134
: $ title ,
110
135
values => (@ values ,),
111
136
: @ labels ,
@@ -115,7 +140,7 @@ multi method process($msg, $query) {
115
140
116
141
my $ msg-response = @ results . reverse . map (*. join : ‘ ’ ). join : “ \n ” ;
117
142
118
- ( $ msg-response , % graph )
143
+ $ msg-response , % graph
119
144
}
120
145
121
146
Statisfiable. new . selfrun: ‘ statisfiable6’ , [/stat6? /, fuzzy-nick(‘ statisfiable6’ , 3 ) ]
0 commit comments