Skip to content

Commit

Permalink
debugging code - use Process.clock_gettime
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg authored and thomthom committed Jul 9, 2024
1 parent 784a0ec commit 038a837
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/testup/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ module Debug
module Timing

def time(title = '', &block)
start = Time.now
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = block.call
lapsed_time = Time.now - start
Log.trace :timing, "Timing #{title}: #{lapsed_time}s"
elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
Log.trace :timing, "Timing #{title}: #{'%.5f' % elapsed_time}s"
result
end

Expand Down
6 changes: 3 additions & 3 deletions src/testup/debugger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def self.debugger_output=(value)

# Time the given block and output it to the system debugger.
def self.time(title, &block)
start = Time.now
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
block.call
ensure
lapsed_time = Time.now - start
self.output("TestUp::Debugger.time: #{title} #{lapsed_time}s")
elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
self.output("TestUp::Debugger.time: #{title} #{'%.5f' % elapsed_time}s")
nil
end

Expand Down

0 comments on commit 038a837

Please sign in to comment.