Class: Benchmarker

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmarker.rb

Class Method Summary collapse

Class Method Details

.add_sigint_handlerObject



29
30
31
32
33
34
# File 'lib/benchmarker.rb', line 29

def add_sigint_handler
  trap 'INT' do
    puts "Bye!"
    raise Interrupt, nil # let the run loop catch it
  end
end

.go(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/benchmarker.rb', line 10

def go(path)
  @path = path
  check_path_exists
  add_sigint_handler
  
  stream = FSEvents::Stream.watch(path) do |events|
    output = capture_stdout do
      yield
    end   
    times << grab_times(output.string).flatten
    display_output
  end
  stream.run
end

.timesObject



25
26
27
# File 'lib/benchmarker.rb', line 25

def times
  @times ||= []
end