Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use 5.10.1;
- use Bugzilla;
- use Storable qw(freeze);
- Bugzilla->extensions;
- sub main::cache_size {
- my $rc = Bugzilla->request_cache;
- my %total;
- state $prev_total;
- foreach (keys %$rc) {
- my $size = eval { length(Storable::freeze(\$rc->{$_})) };
- my $key = $_;
- if (/^Bugzilla::Bug,\d+,\d+/) {
- $key = 'Bugzilla::Bug,_,_';
- }
- if (defined $size) {
- $total{$key} += $size;
- }
- }
- my $result;
- if ($prev_total) {
- my %report;
- foreach (keys %total) {
- if ($total{$_} > $prev_total->{$_} or not exists $prev_total->{$_}) {
- $report{$_} = exists $prev_total->{$_} ? $total{$_} - $prev_total->{$_} : $total{$_};
- }
- }
- $result = join("\n", map { "$_ = $report{$_}" } sort { $report{$a} <=> $report{$b} } keys %report );
- }
- $prev_total = \%total;
- return $result;
- }
Add Comment
Please, Sign In to add comment