getctx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Extract the context switching information from lmbench result files.
  2. # Usage: getctx file file....
  3. #
  4. # Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
  5. # Copyright (c) 1994 Larry McVoy. GPLed software.
  6. # $Id$
  7. eval 'exec perl -Ss $0 "$@"'
  8. if 0;
  9. $title = "foo" if 0;
  10. foreach $file (@ARGV) {
  11. open(FD, $file);
  12. while (<FD>) {
  13. chop;
  14. if (/^\[lmbench/) {
  15. @_ = split;
  16. if ($_[3] eq "SunOS") {
  17. $_[3] .= "-$_[5]";
  18. }
  19. $uname = "@_";
  20. }
  21. if (/Mhz/) {
  22. $mhz = $_;
  23. }
  24. if (/^.size=/) {
  25. s/size/Process size/;
  26. s/ ovr/\toverhead/;
  27. @info = &getinfo($uname, $mhz);
  28. ($f = $file) =~ s|/|-|;
  29. print "tmp/ctx.$f\n";
  30. open(OUT, ">tmp/ctx.$f");
  31. print OUT "\"%X Processes \n\"%Y Time in microseconds\n";
  32. if ($title) {
  33. print OUT "%T $f\n";
  34. } else {
  35. print OUT
  36. "\"%T Context switches for " .
  37. "$info[3] $info[$#info]Mhz\n";
  38. }
  39. print OUT "$_\n";
  40. while (<FD>) {
  41. last if /^Null/ || /^Pipe/ || /^Memor/;
  42. next if /\$Id/;
  43. next if m|scripts/lmbench: /dev/tty|;
  44. s/ ovr/\toverhead/;
  45. s/size/Process size/;
  46. print OUT;
  47. }
  48. close(OUT);
  49. last;
  50. }
  51. }
  52. }
  53. # Try and create sensible names from uname -a output
  54. sub getinfo
  55. {
  56. local(@info);
  57. local($name);
  58. local($mhz);
  59. ($mhz = $_[1]) =~ s/[\. ].*//;
  60. @info = split(/\s+/, $_[0]);
  61. $name = pop(@info);
  62. chop($name);
  63. if ($name eq "mips") {
  64. $name = "$info[$#info]@$mhz";
  65. } elsif ($_[0] =~ /HP-UX/) {
  66. $name = "$info[7]@$mhz";
  67. } elsif ($_[0] =~ /SunOS/) {
  68. $name = "$info[7]@$mhz";
  69. } else {
  70. $name .= "@$mhz";
  71. }
  72. push(@info, $name);
  73. @info;
  74. }