Sha256: 38c6cd3aa595fd970ff4c046feb28a6736647d7f2961bdbcbea07295db2031b7
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require 'cucumber/core/test/result' module Cucumber module Core module Test class Timer def start @start_time = time_in_nanoseconds self end def duration Result::Duration.new(nsec) end def nsec time_in_nanoseconds - @start_time end def sec nsec / 10**9.0 end private def time_in_nanoseconds MonotonicTime.time_in_nanoseconds end module MonotonicTime module_function if defined?(Process::CLOCK_MONOTONIC) def time_in_nanoseconds Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) end elsif (defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby') == 'jruby' def time_in_nanoseconds java.lang.System.nanoTime() end else def time_in_nanoseconds t = Time.now t.to_i * 10**9 + t.nsec end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems