class FileIoMonitor

Public Class Methods

new() click to toggle source
# File lib/load/monitors/file_io_monitor.rb, line 8
def initialize
  @sleep_seconds = 4
end

Public Instance Methods

pause_after_run() click to toggle source
# File lib/load/monitors/file_io_monitor.rb, line 31
def pause_after_run
  sleep @sleep_seconds
end
run() click to toggle source
# File lib/load/monitors/file_io_monitor.rb, line 12
def run
  file_name = "./log/file_io_bench_#{Time.now.to_i}.dat"
  (1..200).each do |i|
    File.open(file_name, 'w') { |file|
      (1..1000).each do |j|
        file.write("Test text #{j} aohoasihdf oiahsdf pohiasdfha oisdhf aiousdfgho iausgdf oaia aiusdhfia hdfihdsfi ahsdfi ahudf \n")
        file.flush
      end
    }

    File.readlines(file_name).each do |line|
      if (!line.start_with? "Test text")
        raise "Error reading back file"
      end
    end
    File.delete(file_name)
  end
end
test_code() click to toggle source
# File lib/load/monitors/file_io_monitor.rb, line 36
def test_code
  return ("monitor.file")
end