Guest User

Untitled

a guest
Jan 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. use 5.10.1;
  2. use Bugzilla;
  3. use Storable qw(freeze);
  4.  
  5. Bugzilla->extensions;
  6. sub main::cache_size {
  7. my $rc = Bugzilla->request_cache;
  8. my %total;
  9. state $prev_total;
  10. foreach (keys %$rc) {
  11. my $size = eval { length(Storable::freeze(\$rc->{$_})) };
  12. my $key = $_;
  13. if (/^Bugzilla::Bug,\d+,\d+/) {
  14. $key = 'Bugzilla::Bug,_,_';
  15. }
  16. if (defined $size) {
  17. $total{$key} += $size;
  18. }
  19. }
  20. my $result;
  21. if ($prev_total) {
  22. my %report;
  23. foreach (keys %total) {
  24. if ($total{$_} > $prev_total->{$_} or not exists $prev_total->{$_}) {
  25. $report{$_} = exists $prev_total->{$_} ? $total{$_} - $prev_total->{$_} : $total{$_};
  26. }
  27. }
  28. $result = join("\n", map { "$_ = $report{$_}" } sort { $report{$a} <=> $report{$b} } keys %report );
  29. }
  30. $prev_total = \%total;
  31. return $result;
  32. }
Add Comment
Please, Sign In to add comment