Changeset 5df7203 for memlog_analyze


Ignore:
Timestamp:
06/01/15 06:25:13 (9 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master
Children:
d270799
Parents:
0109b01
git-author:
Hal Finkel <hfinkel@…> (06/01/15 06:25:13)
git-committer:
Hal Finkel <hfinkel@…> (06/01/15 06:25:13)
Message:

add glob processing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • memlog_analyze

    r9fcaba3 r5df7203  
    1212  my $ec = $_[0]; 
    1313  my $usage = <<EOM; 
    14 Usage: $0 [options] <memlog file> [<output directory>] 
     14Usage: $0 [options] <memlog file or glob> [<output directory>] 
    1515  options: 
    1616    --leaks 
     
    4040 
    4141if (! -f $memlog_fn) { 
     42  my @pot_fns = glob($memlog_fn); 
     43  if (scalar(@pot_fns)) { 
     44    if (!$quiet) { 
     45      print "Searching all files matching '$memlog_fn'\n"; 
     46    } 
     47 
     48    my $pot_max_rss = 0; 
     49    my $pos_max_rss_fn; 
     50    foreach my $pot_fn (@pot_fns) { 
     51      my $last_line = `tail -n 1 '$pot_fn'`; 
     52      chomp($last_line); 
     53 
     54      my @parts = split(/\t/, $last_line); 
     55 
     56      my $op = shift(@parts); 
     57      my $state = shift(@parts); 
     58 
     59      my ($time, $then_max_rss, $tid) = split(/\s+/, $state); 
     60      if ($pot_max_rss < $then_max_rss) { 
     61        $pot_max_rss = $then_max_rss; 
     62        $pos_max_rss_fn = $pot_fn; 
     63      } 
     64    } 
     65 
     66    if (defined $pos_max_rss_fn) { 
     67      $memlog_fn = $pos_max_rss_fn; 
     68      goto have_memlog_fn; 
     69    } 
     70  } 
     71 
    4272  print_usage(1); 
    4373} 
     74have_memlog_fn: 
    4475 
    4576# The version of addr2line and friends that you use can make a big difference, 
Note: See TracChangeset for help on using the changeset viewer.