Sha256: 6e1fa9556778eeb4cd3caeb8ec3b9d6a43fcc09b03d60917984ee4c1506f365a
Contents?: true
Size: 671 Bytes
Versions: 8
Compression:
Stored size: 671 Bytes
Contents
java_import 'java.lang.System' if RUBY_PLATFORM == 'java' module Timing def self.start TimingContext.new end class TimingContext def initialize @jruby = RUBY_PLATFORM == 'java' reset! end def reset! @start = @last_tick = now end def tick rt = runtime_since(@last_tick) @last_tick = now rt end def stop rt = runtime_since(@start) reset! rt end private def now return System.nano_time if @jruby return Time.now.to_f end def runtime_since(start) rt = now - start rt = rt.to_f / 1_000_000_000 if @jruby rt end end end
Version data entries
8 entries across 8 versions & 1 rubygems