Module: Hitimes

Defined in:
lib/hitimes.rb,
lib/hitimes/paths.rb,
lib/hitimes/stats.rb,
lib/hitimes/metric.rb,
lib/hitimes/instant.rb,
lib/hitimes/version.rb,
lib/hitimes/interval.rb,
lib/hitimes/initialize.rb,
lib/hitimes/timed_metric.rb,
lib/hitimes/value_metric.rb,
lib/hitimes/mutexed_stats.rb,
lib/hitimes/timed_value_metric.rb

Overview

– Copyright © 2008, 2009 Jeremy Hinegardner All rights reserved. See LICENSE and/or COPYING for details. ++

Defined Under Namespace

Modules: Initialize, Paths Classes: Error, Interval, Metric, Stats, TimedMetric, TimedValueMetric, ValueMetric

Constant Summary collapse

CLOCK_ID =

Public: The clock_id to use in Process.clock_gettime

Initialize.determine_clock_id.freeze
NANOSECONDS_PER_SECOND =

Internal: The fraction of second of a nanosecond

1e9
VERSION =
"3.0.0"
MutexedStats =

MutexedStats is the start of a threadsafe Stats class. Currently, on MRI Ruby the Stats object is already threadsafe, so there is no need to use MutexedStats.

Stats

Class Method Summary collapse

Class Method Details

.clock_nameObject

Internal: The human readable clock name of the CLOCK_ID as a string

Returns the clock name as a String



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hitimes/instant.rb', line 29

def clock_name
  case CLOCK_ID
  when Symbol
    CLOCK_ID.to_s
  else
    const = Process.constants.grep(/CLOCK/).find do |id|
      Process.const_get(id) == CLOCK_ID
    end
    "Process::#{const}"
  end
end

.measure(&block) ⇒ Object

Hitimes.measure { } -> Float

Times the execution of the block, returning the number of seconds it took



24
25
26
# File 'lib/hitimes.rb', line 24

def self.measure(&block)
  Hitimes::Interval.measure(&block)
end

.raw_instantObject

Public: Get the raw instant

Examples:

Hitimes.raw_instant

Returns the raw instant value



21
22
23
# File 'lib/hitimes/instant.rb', line 21

def raw_instant
  Process.clock_gettime(::Hitimes::CLOCK_ID, :nanosecond)
end