https://github.com/copiousfreetime/hitimes
a fast, high resolution timer library for recording performance metrics
https://github.com/copiousfreetime/hitimes
Keywords
metrics ruby stats
Keywords from Contributors
rubygem multithreading rack libxml2 libxslt nokogiri ruby-gem sax xerces xslt
Last synced: about 14 hours ago
JSON representation
Repository metadata
a fast, high resolution timer library for recording performance metrics
- Host: GitHub
- URL: https://github.com/copiousfreetime/hitimes
- Owner: copiousfreetime
- License: isc
- Created: 2008-09-14T06:52:43.000Z (over 17 years ago)
- Default Branch: main
- Last Pushed: 2025-11-16T00:14:49.000Z (4 months ago)
- Last Synced: 2026-02-12T17:05:08.610Z (19 days ago)
- Topics: metrics, ruby, stats
- Language: Ruby
- Homepage:
- Size: 454 KB
- Stars: 150
- Watchers: 5
- Forks: 18
- Open Issues: 1
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
README.md
Hitimes
DESCRIPTION
A fast, high resolution timer library for recording performance metrics.
TABLE OF CONTENTS
REQUIREMENTS
Hitimes requires the following to run:
- Ruby
USAGE
Hitimes easiest to use when installed with rubygems:
gem install hitimes
Or as part of your bundler Gemfile:
gem "hitimes"
You can load it with the standard ruby require statement.
require "hitimes"
Interval
Use Hitimes::Interval to calculate only the duration of a block of code.
Returns the time as seconds.
duration = Hitimes::Interval.measure do
1_000_000.times do |x|
2 + 2
end
end
puts duration # => 0.047414297 (seconds)
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) }
# do something with result_of_do_something
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
Implementation details
Hitimes uses the internal ruby Process::clock_gettime() to
get the highest granularity time increment possible. Generally this is
nanosecond resolution, or whatever the hardware in the CPU supports.
SUPPORT
Hitimes is supported on whatever versions of ruby are currently supported.
Hitimes also follows semantic versioning.
The current officially supported versions of Ruby are:
- MRI Ruby (all platforms) 3.0 - current
- JRuby 9.4.x.x
- Truffleruby 24
Unofficially supported versions, any version of MRI from Ruby 2.1 and up. Since
the C Extension has been removed Hitimes should work with any ruby that is 2.1
or greater as that is when Process.clock_gettime() was implemented.
For versions of Ruby before 2.1 please use Hitimes 1.3, the extension code is
still in there and they should still work.
CONTRIBUTING
Please read CONTRIBUTING.md for instructions on development
and bug reporting.
Credits
- Bruce Williams for suggesting the idea.
- Benoit Daloze and Thomas Hurst for conversations around clock_ids.
License
Hitimes is licensed under the ISC
license.
Related Works
- monotime - A sensible interface to Ruby's monotonic clock.
- concurrent-ruby - Concurrent.monotonic_time is a straight pass through to
Process.clock_gettime(Process::CLOCK_MONOTONIC,...). - Instant - The rust equivalent.
- time.Now - The go monotonic time interface is part of this package.
Owner metadata
- Name: Jeremy Hinegardner
- Login: copiousfreetime
- Email:
- Kind: user
- Description:
- Website: http://copiousfreetime.org
- Location: Boulder, CO
- Twitter:
- Company: Copious Free Time, LLC
- Icon url: https://avatars.githubusercontent.com/u/11256?v=4
- Repositories: 90
- Last ynced at: 2023-04-09T03:55:19.312Z
- Profile URL: https://github.com/copiousfreetime
GitHub Events
Total
- Delete event: 5
- Pull request event: 11
- Watch event: 5
- Issue comment event: 4
- Push event: 10
- Create event: 5
Last Year
- Delete event: 2
- Pull request event: 4
- Watch event: 2
- Issue comment event: 2
- Create event: 1
Committers metadata
Last synced: 1 day ago
Total Commits: 407
Total Committers: 10
Avg Commits per committer: 40.7
Development Distribution Score (DDS): 0.027
Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Jeremy Hinegardner | j****y@c****g | 396 |
| Olle Jonsson | o****n@g****m | 2 |
| Karol Bucek | k****s | 2 |
| Wojciech Piekutowski | w****h@p****t | 1 |
| Joel Low | j****l@j****g | 1 |
| Jesse Scott | j****e@p****m | 1 |
| Jason Nochlin | h****t | 1 |
| Corban Mailloux | g****b@c****o | 1 |
| Benoit Daloze | e****p@g****m | 1 |
| Julian Kulesh | j****h@k****u | 1 |
Committer domains:
- kupibilet.ru: 1
- corb.co: 1
- puppetlabs.com: 1
- joelsplace.sg: 1
- piekutowski.net: 1
- copiousfreetime.org: 1
Issue and Pull Request metadata
Last synced: 9 days ago
Total issues: 62
Total pull requests: 37
Average time to close issues: 7 months
Average time to close pull requests: 3 months
Total issue authors: 44
Total pull request authors: 15
Average comments per issue: 5.63
Average comments per pull request: 1.22
Merged pull request: 22
Bot issues: 0
Bot pull requests: 10
Past year issues: 0
Past year pull requests: 13
Past year average time to close issues: N/A
Past year average time to close pull requests: 14 days
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 0.23
Past year merged pull request: 7
Past year bot issues: 0
Past year bot pull requests: 6
Top Issue Authors
- copiousfreetime (17)
- ghost (2)
- rdp (2)
- eric (1)
- andreas-venturini (1)
- Rajiv-Silva-ConnectedLab (1)
- lfender6445 (1)
- waldofe (1)
- eregon (1)
- wpiekutowski (1)
- Startouf (1)
- virtualfunction (1)
- tyhawk (1)
- trocolit2 (1)
- ccoenen (1)
Top Pull Request Authors
- copiousfreetime (13)
- dependabot[bot] (10)
- olleolleolle (2)
- taylskid (1)
- raventid (1)
- kares (1)
- corbanmailloux (1)
- hundredwatt (1)
- eregon (1)
- wpiekutowski (1)
- scotje (1)
- fossabot (1)
- lelutin (1)
- lowjoel (1)
- mbautin (1)
Top Issue Labels
- bug (10)
- feature (8)
- release 1.3.0 (2)
Top Pull Request Labels
- dependencies (10)
- ruby (4)
- bug (1)
Package metadata
- Total packages: 13
-
Total downloads:
- rubygems: 122,083,394 total
- Total docker downloads: 518,254,294
- Total dependent packages: 33 (may contain duplicates)
- Total dependent repositories: 34,821 (may contain duplicates)
- Total versions: 160
- Total maintainers: 1
gem.coop: hitimes
A fast, high resolution timer library for recording performance metrics.
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: http://www.rubydoc.info/gems/hitimes/
- Licenses: ISC
- Latest release: 3.1.0 (published about 1 year ago)
- Last Synced: 2026-03-01T07:33:52.693Z (2 days ago)
- Versions: 63
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 61,043,108 Total
- Docker Downloads: 259,127,147
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.214%
- Docker downloads count: 0.41%
- Downloads: 0.446%
- Maintainers (1)
debian-13: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: https://packages.debian.org/trixie/ruby-hitimes
- Licenses: isc
- Latest release: 1.3.1-1 (published 19 days ago)
- Last Synced: 2026-02-13T13:16:18.935Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.569%
- Stargazers count: 1.026%
- Forks count: 1.251%
rubygems.org: hitimes
A fast, high resolution timer library for recording performance metrics.
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: http://www.rubydoc.info/gems/hitimes/
- Licenses: ISC
- Latest release: 3.1.0 (published about 1 year ago)
- Last Synced: 2026-02-28T20:00:39.071Z (3 days ago)
- Versions: 63
- Dependent Packages: 33
- Dependent Repositories: 34,821
- Downloads: 61,040,286 Total
- Docker Downloads: 259,127,147
-
Rankings:
- Dependent repos count: 0.178%
- Downloads: 0.371%
- Docker downloads count: 0.503%
- Dependent packages count: 0.728%
- Average: 2.138%
- Stargazers count: 4.64%
- Forks count: 6.405%
- Maintainers (1)
proxy.golang.org: github.com/copiousfreetime/hitimes
- Homepage:
- Documentation: https://pkg.go.dev/github.com/copiousfreetime/hitimes#section-documentation
- Licenses: isc
- Latest release: v3.1.0+incompatible (published about 1 year ago)
- Last Synced: 2026-02-28T20:00:40.283Z (3 days ago)
- Versions: 24
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Stargazers count: 3.995%
- Forks count: 5.068%
- Average: 7.36%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
debian-10: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: https://packages.debian.org/buster/ruby-hitimes
- Licenses:
- Latest release: 1.2.1-3 (published 20 days ago)
- Last Synced: 2026-02-13T04:22:10.944Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-11: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: https://packages.debian.org/bullseye/ruby-hitimes
- Licenses:
- Latest release: 1.2.1-4 (published 20 days ago)
- Last Synced: 2026-02-13T08:21:16.249Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.10: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Licenses:
- Latest release: 1.3.1-1build3 (published 18 days ago)
- Last Synced: 2026-02-13T18:22:37.117Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Licenses:
- Latest release: 1.3.1-1build3 (published 20 days ago)
- Last Synced: 2026-02-11T06:40:53.313Z (20 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-20.04: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Licenses:
- Latest release: 1.2.1-3build6 (published 18 days ago)
- Last Synced: 2026-02-13T07:14:59.939Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Licenses:
- Latest release: 1.3.1-1build1 (published 18 days ago)
- Last Synced: 2026-02-13T13:18:26.465Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-hitimes
- Homepage: https://github.com/copiousfreetime/hitimes
- Documentation: https://packages.debian.org/bookworm/ruby-hitimes
- Licenses:
- Latest release: 1.3.1-1 (published 18 days ago)
- Last Synced: 2026-02-12T23:32:08.393Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
Dependencies
- docile 1.4.0
- hitimes 2.0.0
- json 2.6.1
- minitest 5.15.0
- minitest-focus 1.3.1
- psych 4.0.3
- rake 12.3.3
- rdoc 6.4.0
- simplecov 0.21.2
- simplecov-html 0.12.3
- simplecov_json_formatter 0.1.4
- stringio 3.0.1
- heel >= 0
- minitest ~> 5.11
- minitest-focus ~> 1.2
- minitest-junit ~> 1.0
- rake >= 0
- rdoc ~> 6.3
- reek >= 0
- rubocop ~> 1.63
- rubocop-md ~> 1.2
- rubocop-minitest ~> 0.35
- rubocop-packaging ~> 0.5
- rubocop-performance ~> 1.21
- rubocop-rake ~> 0.6
- rubocop-thread_safety ~> 0.5
- simplecov ~> 0.22
Score: 27.59742674566438