OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

  1. #!/usr/bin/perl -w
  2. #
  3. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. #
  6. # Filename: package/.../oprofile/pulpstoner.pl
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. use English;
  18. use strict;
  19. my $min_samples = 1000;
  20. my $min_percent = 2;
  21. my $min_points = 10;
  22. my %roots;
  23. my %percents;
  24. my %files;
  25. my %binaries;
  26. my $bin;
  27. sub read_pkgdb($) {
  28. my $root=$_[0];
  29. print "Reading package DB from /$root ...\n";
  30. open(F, "cat /${root}var/adm/flists/*|") || die $!;
  31. while (<F>) {
  32. chomp; @_ = split /:\s+/;
  33. $files{${root}.$_[1]} = $_[0];
  34. }
  35. close F;
  36. }
  37. read_pkgdb("");
  38. my $pc = 0;
  39. open(F, "opreport -f -n | sort -r -g -k 2|") || die $!;
  40. for (<F>) {
  41. @_ = split /\s+/; $pc+=$_[2];
  42. last if $_[1] < $min_samples;
  43. last if $pc > 100-$min_percent;
  44. next unless -f $_[3];
  45. $_[3] =~ s,^/,,;
  46. $binaries{$_[3]} = $_[2];
  47. }
  48. close F;
  49. foreach $bin (keys %binaries) {
  50. if ( $bin =~ m,(.*/root/), and not defined $roots{$1} ) {
  51. $roots{$1} = 1;
  52. read_pkgdb($1);
  53. }
  54. if ( not defined $files{$bin} ) {
  55. print "Not found in package db: $bin\n";
  56. next;
  57. }
  58. open(F, "opreport -g --symbols -n /$bin|") || die $!;
  59. while (<F>) {
  60. next if /\(no location information\)/;
  61. my ($count, $percent, $src, $sym) = split /\s+/; $src =~ s/:.*//;
  62. $percents{sprintf "%-14s\t%-22s\t%s",
  63. $files{$bin}, $src, $bin} += $percent * $binaries{$bin};
  64. }
  65. close F;
  66. }
  67. foreach (keys %percents) {
  68. next if $percents{$_} < $min_points;
  69. printf "** %9.2f:\t%s\n", $percents{$_}, $_;
  70. }