github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

copiousfreetime / hitimes

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 10
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (1)
  • Downloads (9)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (9)
    • v1.0.1
    • v1.0.0
    • v0.4.1
    • v0.4.0
    • v0.3.0
    • v0.2.1
    • v0.2.0
    • 1.0.4
    • 1.0.3
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

a fast, high resolution timer library for recording performance metrics — Read more

  cancel

http://copiousfreetime.rubyforge.org/hitimes

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

version bump 
copiousfreetime (author)
Sat Aug 01 14:59:57 -0700 2009
commit  996b0c8d7b77b19ab5de86afa756e30066803016
tree    5836ef586540d483e6cf7446017c45da28338577
parent  b32bad4ef5403f84b5ce309b693a7a24f515fa0a
hitimes /
name age
history
message
file .gitignore Loading commit data...
file HISTORY
file LICENSE
file README
file Rakefile
file TODO.taskpaper
directory examples/
directory ext/
file gemspec.rb
directory lib/
directory spec/
directory tasks/
README
== hitimes

* Homepage[http://copiousfreetime.rubyforge.org/hitimes] 
* {Rubyforge project}[http://rubyforge.org/projects/copiousfreetime/]
* email jeremy at copiousfreetime dot org
* git clone url git://github.com/copiousfreetime/hitimes.git

== INSTALL

* gem install hitimes

== DESCRIPTION

Hitimes is a fast, high resolution timer library for recording
performance metrics.  It uses the appropriate C method calls for each
system to get the highest granularity time increments possible.  

It currently supports any of the following systems:

* any system with the POSIX call <tt>clock_gettime()</tt>,
* Mac OS X
* Windows

Using Hitimes can be faster than using a series of +Time.new+ calls, and
it will have a much higher granularity.   It is definitely faster than
using +Process.times+. 

== SYNOPSIS

=== Interval

Use Hitimes::Interval to calculate only the duration of a block of code

  duration = Hitimes::Interval.measure do
               # some operation ...
             end

  puts duration   

=== TimedMetric

Use a Hitimes::TimedMetric to calculate statistics about an iterative operation

  timed_metric = Hitimes::TimedMetric.new('operation on items')

Explicitly use +start+ and +stop+:

  collection.each do |item|
    timed_metric.start
    # .. do something with item
    timed_metric.stop
  end

Or use the block.  In TimedMetric the return value of +measure+ is the return
value of the block

  collection.each do |item|
    result_of_do_something = timed_metric.measure { do_something( item ) }
  end

And then look at the stats

  puts timed_metric.mean
  puts timed_metric.max
  puts timed_metric.min
  puts timed_metric.stddev
  puts timed_metric.rate

=== ValueMetric 

Use a Hitimes::ValueMetric to calculate statistics about measured samples

  value_metric = Hitimes::ValueMetric.new( 'size of thing' )
  loop do
    # ... do stuff changing sizes of 'thing'
    value_metric.measure( thing.size )
    # ... do other stuff that may change size of thing
  end

  puts value_metric.mean
  puts value_metric.max
  puts value_metric.min
  puts value_metric.stddev
  puts value_metric.rate


=== TimedValueMetric

Use a Hitimes::TimedValueMetric to calculate statistics about batches of samples

  timed_value_metric = Hitimes::TimedValueMetric.new( 'batch times' )
  loop do 
    batch = ... # get a batch of things
    timed_value_metric.start
    # .. do something with batch
    timed_value_metric.stop( batch.size )
  end

  puts timed_value_metric.rate

  puts timed_value_metric.timed_stats.mean
  puts timed_value_metric.timed_stats.max
  puts timed_value_metric.timed_stats.min
  puts timed_value_metric.timed_stats.stddev

  puts timed_value_metric.value_stats.mean
  puts timed_value_metric.value_stats.max
  puts timed_value_metric.value_stats.min
  puts timed_value_metric.value_stats.stddev


== CHANGES

Read the HISTORY file.

== CREDITS

* Bruce Williams for suggesting the idea

== ISC License

Copyright (c) 2008 Jeremy Hinegardner

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server