{"id":26701612,"url":"https://github.com/asungur/hop_timer","last_synced_at":"2025-03-27T01:29:38.013Z","repository":{"id":56876631,"uuid":"288207670","full_name":"asungur/hop_timer","owner":"asungur","description":"\"A ruby gem that calculates runtime between user defined checkpoints.\"","archived":false,"fork":false,"pushed_at":"2020-08-28T23:48:52.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-19T03:35:36.017Z","etag":null,"topics":["ruby","ruby-gem","rubygem","rubygems"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asungur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-17T14:51:06.000Z","updated_at":"2023-02-03T05:22:29.000Z","dependencies_parsed_at":"2022-08-20T23:10:28.091Z","dependency_job_id":null,"html_url":"https://github.com/asungur/hop_timer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asungur%2Fhop_timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asungur%2Fhop_timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asungur%2Fhop_timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asungur%2Fhop_timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asungur","download_url":"https://codeload.github.com/asungur/hop_timer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245764252,"owners_count":20668368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","ruby-gem","rubygem","rubygems"],"created_at":"2025-03-27T01:29:37.268Z","updated_at":"2025-03-27T01:29:38.003Z","avatar_url":"https://github.com/asungur.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HopTimer\n[![Build Status](https://travis-ci.com/asungur/hop_timer.svg?token=yG7xo2a5AcaKbqTNd23W\u0026branch=master)](https://travis-ci.com/asungur/hop_timer)\n[![Gem Version](https://badge.fury.io/rb/hop_timer.svg)](https://badge.fury.io/rb/hop_timer)\n![HopTimer Demo](https://media.giphy.com/media/kG8P3arKGzpMphCfGC/source.gif)\n\nHopTimer is a user friendly benchmarking gem that works as a wrapper for Ruby's default benchmark utility. If you are frequently using benchmark and looking for a more intuitive solution or even planning to start benchmarking in general, HopTimer is for you.\n\nHopTimer uses **check points** and evaluates the runtime between two. As you develop your application define instances of check points and evaluate them whenever you want.\n\n## **Installation**\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hop_timer'\n```\n\nAnd then execute:\n\n```ruby\n$ bundle install\n```\n\nOr install it yourself as:\n\n```ruby\n$ gem install hop_timer\n```\n\n## **Usage**\n\nOnce **HopTimer** is installed on your machine, `require` the gem.\n\n```ruby\nrequire 'hop_timer'\n```\n\n`HopTimer.eval` calculates the runtime between the instances of `HopTimer::CheckPoint` . It logs a table to the console and provides the same values in a form of hash.\n\n```ruby\nflag1 = HopTimer::CheckPoint.new('flag1')\n\nsleep 1.2 # OPERATIONS THAT YOU WANT TO BENCHMARK HERE\n\nflag2 = HopTimer::CheckPoint.new('flag2')\n\nHopTimer.eval(flag1, flag2) \n# RETURNS =\u003e \n{\"user\"=\u003e\"0.000022\",\n\"system\"=\u003e\"0.000045\",\n\"total\"=\u003e\"0.000067\",\n\"real\"=\u003e\"1.201469\"}\n\n# LOGS TO THE CONSOLE =\u003e\n=============Runtime between flag1 and flag2=============\n┌-------------┬-------------┬-------------┬-------------┐\n|    user     |   system    |    total    |    real     |\n├-------------┼-------------┼-------------┼-------------┤\n|  0.000022   |  0.000045   |  0.000067   | 1.201469(s) |\n└-------------┴-------------┴-------------┴-------------┘\n```\n\nThe table breakdowns the runtime as [CPU time](https://en.wikipedia.org/wiki/CPU_time)(user time, system time) and [real time](https://ruby-doc.org/core-2.6.3/Time.html) in seconds. HopTimer uses [Process](https://ruby-doc.org/core-2.6.1/Process.html) and [Benchmark::Tms](https://ruby-doc.org/stdlib-2.4.0/libdoc/benchmark/rdoc/Benchmark/Tms.html) for the calculation.\n\nThe values provided with the returned hash can be specified as floats or strings(default).\n\n```ruby\nHopTimer.eval(flag1, flag2, :string)\n{\"user\"=\u003e\"0.000022\",\n\"system\"=\u003e\"0.000045\",\n\"total\"=\u003e\"0.000067\",\n\"real\"=\u003e\"1.201469\"}\n\nHopTimer.eval(flag1, flag2, :float) # OR\nHopTimer.eval(flag1, flag2, :number)\n{\"user\"=\u003e3.9e-11,\n\"system\"=\u003e2.5e-11,\n\"total\"=\u003e6.4e-11,\n\"real\"=\u003e1.201488e-06}\n```\n\n## **Development**\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/asungur/hop_timer](https://github.com/%5BUSERNAME%5D/hop_timer).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasungur%2Fhop_timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasungur%2Fhop_timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasungur%2Fhop_timer/lists"}