{"id":29175766,"url":"https://github.com/igorkasyanchuk/time_m","last_synced_at":"2025-08-08T12:10:10.545Z","repository":{"id":301034026,"uuid":"1004587619","full_name":"igorkasyanchuk/time_m","owner":"igorkasyanchuk","description":"The easiest way to measure execution time of your code","archived":false,"fork":false,"pushed_at":"2025-06-22T13:54:38.000Z","size":1201,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-28T15:53:20.741Z","etag":null,"topics":["ruby","ruby-on-rails"],"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/igorkasyanchuk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-18T21:38:37.000Z","updated_at":"2025-07-11T05:50:03.000Z","dependencies_parsed_at":"2025-06-24T21:00:40.608Z","dependency_job_id":"38047305-39e4-451d-94d0-dcec40445b7c","html_url":"https://github.com/igorkasyanchuk/time_m","commit_stats":null,"previous_names":["igorkasyanchuk/time_m"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/igorkasyanchuk/time_m","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorkasyanchuk%2Ftime_m","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorkasyanchuk%2Ftime_m/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorkasyanchuk%2Ftime_m/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorkasyanchuk%2Ftime_m/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorkasyanchuk","download_url":"https://codeload.github.com/igorkasyanchuk/time_m/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorkasyanchuk%2Ftime_m/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268675515,"owners_count":24288285,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-on-rails"],"created_at":"2025-07-01T16:09:25.191Z","updated_at":"2025-08-08T12:10:10.515Z","avatar_url":"https://github.com/igorkasyanchuk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Time.measure\n\nThe easiest way to measure execution time of your code. No more `puts` or `logger.info` with `Time.now - time`.\n\nStart measuring your code, and if you value your time, use this gem :)\n\n## Installation\n\n```ruby\ngroup :development, :test do\n  gem \"time_m\"\nend\n```\n\n## Usage\n\nTo make is super easy to use, it extends `Time` class with `m` (or `measure`) method. There is also an advanced way to use it, see below.\n\n```ruby\ndef index\n  Time.m(\"report_time\") do\n    @report = prepare_some_report\n  end\nend\n\n# or\n\ndef index\n  Time.m\n  some_method_1\n  Time.m\n  some_method_2\n  Time.m\n  some_method_3\n  Time.m\nend\n```\n\n## How it works\n\nUnder the hood, it uses `Process.clock_gettime(Process::CLOCK_MONOTONIC)` to get the current time.\n\nAfter first call, it stores the time in a thread-local variable using `Thread.current`.\n\nWith second call, it calculates the difference between the current time and the time stored in the thread-local variable.\n\n## Advanced usage\n\nSupport of multiple timers. You can call any method (it's using `method_missing` under the hood) to start a new timer with it's name.\n\nIt will print duration if the same method is called again.\n\n```ruby\ndef index\n  TM.index\n  TM.some_method_1\n  some_method_1\n  TM.some_method_1\n  TM.some_method_2\n  some_method_2\n  TM.some_method_2\n  TM.index\nend\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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## TODO\n\n- config for colors\n- config to specify print of caller\n- config to enable extension for Time class\n- config for custom output\n- Instrumentation support?\n\n## Contributing\n\nYou are welcome to contribute to the project.\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%2Figorkasyanchuk%2Ftime_m","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorkasyanchuk%2Ftime_m","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorkasyanchuk%2Ftime_m/lists"}