Module: Spectre::Diagnostic::Stopwatch

Defined in:
lib/spectre/diagnostic.rb

Constant Summary collapse

@@duration =
0.0

Class Method Summary collapse

Class Method Details

.durationObject



23
24
25
# File 'lib/spectre/diagnostic.rb', line 23

def duration
  @@end_time - @@start_time
end

.finished_atObject



31
32
33
# File 'lib/spectre/diagnostic.rb', line 31

def finished_at
  @@end_time
end

.measureObject



17
18
19
20
21
# File 'lib/spectre/diagnostic.rb', line 17

def measure
  start_watch
  yield
  stop_watch
end

.start_watchObject



9
10
11
# File 'lib/spectre/diagnostic.rb', line 9

def start_watch
  @@start_time = Time.now
end

.started_atObject



27
28
29
# File 'lib/spectre/diagnostic.rb', line 27

def started_at
  @@start_time
end

.stop_watchObject



13
14
15
# File 'lib/spectre/diagnostic.rb', line 13

def stop_watch
  @@end_time = Time.now
end