[Swift-commit] r2792 - in usertools/cio/tools: . strace

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Mar 31 20:26:22 CDT 2009


Author: aespinosa
Date: 2009-03-31 20:26:21 -0500 (Tue, 31 Mar 2009)
New Revision: 2792

Added:
   usertools/cio/tools/strace/
   usertools/cio/tools/strace/iostats.rb
Log:
Imported IO statistics summarizer ruby script

Added: usertools/cio/tools/strace/iostats.rb
===================================================================
--- usertools/cio/tools/strace/iostats.rb	                        (rev 0)
+++ usertools/cio/tools/strace/iostats.rb	2009-04-01 01:26:21 UTC (rev 2792)
@@ -0,0 +1,51 @@
+#!/home/aespinosa/local/bin/ruby -na
+#
+
+BEGIN {
+  READ = 'read\('
+  OPEN = 'open\('
+  WRITE = 'write\('
+  $desc = {}
+  $read = Hash.new(0)
+  $write = Hash.new(0)
+  $desc[0] = "STDIN"
+  $desc[1] = "STDOUT"
+  $desc[2] = "STDERR"
+  def tosec(time)
+    x=time.split(/:/)
+	x[0].to_f * 3600.0 + x[1].to_f * 60.0 + x[2].to_f
+  end
+}
+
+now = $F[0]
+retcode = $_.split("=")[1].to_i
+if $_ =~ /\(.*\)/
+  args = $&.gsub( /^\(|\)$/, "" ).split ','
+end
+
+if $. == 1
+  start = tosec(now)
+end
+
+if $_ =~ /#{READ}/
+ file = $desc[ args[0].to_i ]
+ $read[file] += retcode
+elsif $_ =~ /#{WRITE}/
+ file = $desc[ args[0].to_i ]
+ $write[file] += retcode
+elsif $_ =~ /#{OPEN}/ and retcode > -1
+  $desc[retcode] = args[0].gsub(/"/,"")
+end
+
+prev = now
+
+END {
+  puts "Read summary\n------------"
+  $read.each { |file, size|
+    puts "#{file}: #{size} bytes"
+  }
+  puts "Write summary\n-----------"
+  $write.each { |file, size|
+    puts "#{file}: #{size} bytes"
+  }
+}


Property changes on: usertools/cio/tools/strace/iostats.rb
___________________________________________________________________
Name: svn:executable
   + *




More information about the Swift-commit mailing list