{"id":26201881,"url":"https://github.com/sveredyuk/perforator","last_synced_at":"2026-05-26T05:02:30.025Z","repository":{"id":56887816,"uuid":"93159135","full_name":"sveredyuk/perforator","owner":"sveredyuk","description":"Simple and pretty stupid way to measure execution time of your code","archived":false,"fork":false,"pushed_at":"2018-06-25T07:57:27.000Z","size":15,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T21:18:07.750Z","etag":null,"topics":["logging","measurements","performance","ruby"],"latest_commit_sha":null,"homepage":"https://github.com/sveredyuk/perforator","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/sveredyuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-02T11:27:03.000Z","updated_at":"2023-11-05T20:43:23.000Z","dependencies_parsed_at":"2022-08-21T00:50:51.780Z","dependency_job_id":null,"html_url":"https://github.com/sveredyuk/perforator","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveredyuk%2Fperforator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveredyuk%2Fperforator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveredyuk%2Fperforator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveredyuk%2Fperforator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sveredyuk","download_url":"https://codeload.github.com/sveredyuk/perforator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243148224,"owners_count":20243940,"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":["logging","measurements","performance","ruby"],"created_at":"2025-03-12T03:24:11.576Z","updated_at":"2025-12-26T05:02:39.306Z","avatar_url":"https://github.com/sveredyuk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/sveredyuk/perforator.svg?branch=master)](https://travis-ci.org/sveredyuk/perforator)\n\n# Perforator\n\n### Simple and pretty stupid way to measure execution time of your code\n\nQuick example\n```ruby\nmeter = Perforator::Meter.new(puts: true)\n\nmeter.call do\n  sleep 1 # doing some serious job\nend\n\n# =======\u003e\n# Start: 2017-06-02 14:24:53 +0300\n# Finish: 2017-06-02 14:24:54 +0300\n# Spent: 1.000919\n```\n\nMore details below\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'perforator'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install perforator\n\n## Usage\n\n### Options\nYou can init new meter object with following arguments:\n\n```ruby\nmy_meter = Perforator::Meter.new(\n  name: 'your label', # -\u003e meter name, just label for passing in start line # =======\u003e your label\n  logger: Logger.new('my_logger.log'), # -\u003e logger object, will receive :info at each step\n  puts: true, # -\u003e true/false output to STDOUT\n  expected_time: 10, # -\u003e time in seconds (!) that expected for execution\n  positive_callback: proc { puts ':)' }, # -\u003e executed if real execution less than expected\n  negative_callback: proc { puts ':(' } # -\u003e executed if real execution more than expected\n)\n```\n\n\nYou can skip any option if you don't need it.\n\nBut for callbacks :expected_time is necessary:\n```ruby\nPerforator::Meter.new(positive_callback: -\u003e { puts ':)' }) #=\u003e NoExpectedTimeError\n```\n\nCallbacks must be callable:\n```ruby\nPerforator::Meter.new(positive_callback: Hash.new) #=\u003e NotCallableCallbackError\n\n```\n\nExpeted time must be fixnum:\n```ruby\nPerforator::Meter.new(expected_time: '10') #=\u003e NotFixnumExpectedTimeError\n\n```\n\nJust wrap your code with meter:\n```ruby\nmy_meter.call do\n  # put your code here\nend\n```\n\nUse `log!` method to log additional info\n```ruby\nmy_meter.call do |meter|\n  meter.log! 'Any start value'\n  # put your code here\n  meter.some_finish 'Some finish value'\nend\n\n# =======\u003e your label\n# Any start value\n# Start: 2017-06-02 14:24:53 +0300\n# Finish: 2017-06-02 14:24:54 +0300\n# Spent: 1.000919\n# Some finish value\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` 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/sveredyuk/perforator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsveredyuk%2Fperforator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsveredyuk%2Fperforator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsveredyuk%2Fperforator/lists"}