Sha256: d6575d21a3389298dc77be969ed2b878b9d54abcdb757ae652a6784b7400790f
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 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
5 entries across 5 versions & 1 rubygems