sortprof 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/perl
  2. ##
  3. ## Profiler output munching program, run this on your driver.log if you are
  4. ## running with profiling, as:
  5. ##
  6. ## sortprof < driver.log | more
  7. ##
  8. ## -Brandon Gillespie
  9. ##
  10. ### threshold, dont print out methods with less hits than this
  11. $thresh = 50;
  12. ### dont bother with anything past this
  13. $dops = 0;
  14. $dmeths = 0;
  15. @ops = ();
  16. @meths = ();
  17. while (<STDIN>) {
  18. chomp;
  19. if (/^Methods/) {
  20. $dops=0;
  21. $dmeths=1;
  22. } elsif (/^Opcodes/) {
  23. $dops=1;
  24. $dmeths=0;
  25. # } elsif ($dops) {
  26. # s/^\s*//;
  27. # ($count, $opcode, $op) = split(/\s+/);
  28. # if ($count > $thresh) {
  29. # push(@ops, "$count:$op");
  30. # }
  31. } elsif ($dmeths) {
  32. s/^\s*//;
  33. ($count, $meth) = split(/\s+/);
  34. if ($count > $thresh) {
  35. push(@meths, "$count:$meth");
  36. }
  37. }
  38. }
  39. #print ("Opcodes:\n");
  40. #for (sort({$b <=> $a} @ops)) {
  41. # ($count, $op) = split(/:/);
  42. # printf(" %-10ld $op\n", $count);
  43. #}
  44. print ("Methods:\n");
  45. for (sort({$b <=> $a} @meths)) {
  46. ($count, $m) = split(/:/);
  47. printf(" %-10ld $m\n", $count);
  48. }