Class: SysBench::IO
- Inherits:
-
Object
- Object
- SysBench::IO
- Defined in:
- lib/sysbench/io.rb
Instance Attribute Summary collapse
-
#avg ⇒ Object
Returns the value of attribute avg.
-
#block_size ⇒ Object
Returns the value of attribute block_size.
-
#byte_rate ⇒ Object
Returns the value of attribute byte_rate.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#request_rate ⇒ Object
Returns the value of attribute request_rate.
-
#test ⇒ Object
Returns the value of attribute test.
-
#threads ⇒ Object
Returns the value of attribute threads.
-
#top ⇒ Object
Returns the value of attribute top.
-
#total_size ⇒ Object
Returns the value of attribute total_size.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(file) ⇒ IO
constructor
A new instance of IO.
- #parse(str) ⇒ Object
-
#to_s(delim = "\t") ⇒ Object
parse.
Constructor Details
#initialize(file) ⇒ IO
Returns a new instance of IO.
10 11 12 13 14 15 16 |
# File 'lib/sysbench/io.rb', line 10 def initialize(file) if not File.exists? file then puts "File '#{file}' does not exist!" exit end parse(File.new(file).read) end |
Instance Attribute Details
#avg ⇒ Object
Returns the value of attribute avg.
8 9 10 |
# File 'lib/sysbench/io.rb', line 8 def avg @avg end |
#block_size ⇒ Object
Returns the value of attribute block_size.
6 7 8 |
# File 'lib/sysbench/io.rb', line 6 def block_size @block_size end |
#byte_rate ⇒ Object
Returns the value of attribute byte_rate.
7 8 9 |
# File 'lib/sysbench/io.rb', line 7 def byte_rate @byte_rate end |
#max ⇒ Object
Returns the value of attribute max.
8 9 10 |
# File 'lib/sysbench/io.rb', line 8 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
8 9 10 |
# File 'lib/sysbench/io.rb', line 8 def min @min end |
#request_rate ⇒ Object
Returns the value of attribute request_rate.
7 8 9 |
# File 'lib/sysbench/io.rb', line 7 def request_rate @request_rate end |
#test ⇒ Object
Returns the value of attribute test.
5 6 7 |
# File 'lib/sysbench/io.rb', line 5 def test @test end |
#threads ⇒ Object
Returns the value of attribute threads.
5 6 7 |
# File 'lib/sysbench/io.rb', line 5 def threads @threads end |
#top ⇒ Object
Returns the value of attribute top.
8 9 10 |
# File 'lib/sysbench/io.rb', line 8 def top @top end |
#total_size ⇒ Object
Returns the value of attribute total_size.
6 7 8 |
# File 'lib/sysbench/io.rb', line 6 def total_size @total_size end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/sysbench/io.rb', line 5 def version @version end |
Instance Method Details
#parse(str) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sysbench/io.rb', line 18 def parse(str) str.split(/\n/).each do |l| l.strip! if l =~ /^sysbench (.+?):/ @version = $1 elsif l =~ /^Number of threads: (\d+)$/ @threads = $1 elsif l =~ /^Doing (.+?) test$/ @test = $1 elsif l =~ /^(.+?) total file size$/ @total_size = $1 elsif l =~ /^Block size (.+?)$/ @block_size = $1 elsif l =~ /Read [\dKMGTb.]+ Written [\dKMGTb.]+ Total transferred [\dKMGTb.]+ \((.+?)\)/ @byte_rate = $1 elsif l =~ /^(.+?) Requests\/sec executed$/ @request_rate = $1 elsif l =~ /min:\s+(.+?)$/ @min = $1 elsif l =~ /max:\s+(.+?)$/ @max = $1 elsif l =~ /avg:\s+(.+?)$/ @avg = $1 elsif l =~ /approx.*?:\s+(.+?)$/ @top = $1 end end # each end |
#to_s(delim = "\t") ⇒ Object
parse
58 59 60 |
# File 'lib/sysbench/io.rb', line 58 def to_s(delim = "\t") [@test, @threads, @total_size, @block_size, @byte_rate, @request_rate, @min, @max, @avg, @top].join("\t") end |