Leaked source code of windows server 2003
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.

88 lines
1.8 KiB

  1. @rem = '
  2. @perl.exe -w %~f0 %*
  3. @goto :EOF
  4. '; undef @rem;
  5. sub readMon {
  6. my ($file, $fnum) = @_;
  7. open (FILE, $file) || die "$file not found.\n";
  8. $_ = <FILE>; # Skip first line
  9. while (<FILE>) {
  10. @c = split;
  11. if (defined($c[0]) && $c[0] =~ /^\d+$/) {
  12. $funname = $c[3];
  13. $count{$funname}[$fnum] = $c[0];
  14. $total_time{$funname}[$fnum] = $c[1];
  15. # print "$c[0],$c[1],$c[2],$c[3]\n";
  16. }
  17. }
  18. close (FILE);
  19. }
  20. sub printInt {
  21. my ($x) = @_;
  22. if (defined($x)) {
  23. printf ("%7d ", $x);
  24. } else {
  25. printf (" " x 8);
  26. }
  27. }
  28. sub printPercentage {
  29. my ($x) = @_;
  30. if (defined($x)) {
  31. printf ("%+7.1f ", $x);
  32. } else {
  33. printf (" " x 8);
  34. }
  35. }
  36. # Diffs the "monitor" output for two different runs.
  37. $syntax = "Syntax: diffmonitors <file1> <file2>\n";
  38. ($#ARGV == 1) || die $syntax;
  39. @file = @ARGV;
  40. &readMon($file[0], 0);
  41. &readMon($file[1], 1);
  42. print " Count1 Time1 Count2 Time2 dCount dTime Function\n".
  43. "(calls) (�s) (calls) (�s) (%) (%)\n\n";
  44. foreach $fun (sort keys %count) {
  45. undef $c0; undef $c1; undef $t0; undef $t1;
  46. $bothdefined = 1;
  47. if (defined($count{$fun}[0])) {
  48. $c0 = $count{$fun}[0];
  49. $t0 = $total_time{$fun}[0];
  50. } else {
  51. $bothdefined = 0;
  52. }
  53. if (defined($count{$fun}[1])) {
  54. $c1 = $count{$fun}[1];
  55. $t1 = $total_time{$fun}[1];
  56. } else {
  57. $bothdefined = 0;
  58. }
  59. undef $dc; undef $dt;
  60. if ($bothdefined && $c0 && $c1) {
  61. $dc = 100 * (($c1 - $c0) / $c0);
  62. }
  63. if ($bothdefined && $t0 && $t1) {
  64. $dt = 100 * (($t1 - $t0) / $t0);
  65. }
  66. &printInt($c0);
  67. &printInt($t0);
  68. &printInt($c1);
  69. &printInt($t1);
  70. &printPercentage($dc);
  71. &printPercentage($dt);
  72. print "$fun\n";
  73. }