Class: Time

Inherits:
Object show all
Includes:
Lite::Ruby::DateHelper, Lite::Ruby::TimeHelper
Defined in:
lib/lite/ruby/time.rb

Constant Summary

Constants included from Lite::Ruby::TimeHelper

Lite::Ruby::TimeHelper::TIME_UNITS

Class Method Summary collapse

Methods included from Lite::Ruby::DateHelper

#format, #stamp

Class Method Details

.elapse(verbose: false) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/lite/ruby/time.rb', line 11

def elapse(verbose: false)
  started_at = now.to_f
  yield
  ended_at = now.to_f
  runtime = ended_at - started_at
  return runtime unless verbose

  { started_at: started_at, ended_at: ended_at, runtime: runtime }
end