{"id":15792775,"url":"https://github.com/marioruiz/timify","last_synced_at":"2025-08-20T00:05:19.155Z","repository":{"id":56897020,"uuid":"109708640","full_name":"MarioRuiz/timify","owner":"MarioRuiz","description":"Ruby gem to easily calculate the time running (elapsed time) from one location to another inside your code and reports statistics. It helps you improve your code and find out which part of your code is consuming more time.","archived":false,"fork":false,"pushed_at":"2021-05-27T17:19:21.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T02:41:42.585Z","etag":null,"topics":["consumer","count","elapsed","ruby","ruby-gem","statistics","time","timify"],"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/MarioRuiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-06T14:51:48.000Z","updated_at":"2021-05-27T17:19:23.000Z","dependencies_parsed_at":"2022-08-20T17:40:32.955Z","dependency_job_id":null,"html_url":"https://github.com/MarioRuiz/timify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioRuiz%2Ftimify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioRuiz%2Ftimify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioRuiz%2Ftimify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioRuiz%2Ftimify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarioRuiz","download_url":"https://codeload.github.com/MarioRuiz/timify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246523897,"owners_count":20791444,"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":["consumer","count","elapsed","ruby","ruby-gem","statistics","time","timify"],"created_at":"2024-10-04T23:04:12.536Z","updated_at":"2025-03-31T18:51:24.189Z","avatar_url":"https://github.com/MarioRuiz.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Timify\n\n[![Gem Version](https://badge.fury.io/rb/timify.svg)](https://rubygems.org/gems/timify)\n\nEasily calculates the time running (elapsed time) from one location to another inside your code and reports statistics. It helps you improve your code and find out which part of your code is consuming more time.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'timify'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install timify\n\n## Usage\n\n### initialize\nYou need to supply a name for your Timify instance. \nYou can have all the Timify instances you want at the same time.\n```ruby\nt = Timify.new :create_user\nt.show = false\nt.min_time_to_show = 0.5\n```\nmin_time_to_show: minimum time to show the elapsed time when calling 'add' method\n\nshow: print out results on screen\n\nyou can supply those parameters also:\n\n```ruby\nt = Timify.new :create_user, show: true, min_time_to_show: 0.3\n```\n\nThe scopes of the instances can be even global so you can measure the elapsed times between different classes, methods... on your code.\n\nYou can disable the timify counter whenever you want using the status attritute that admits :on or :off, by default is set to :on\n\n```ruby\nt.status = :off\n```\n\n### add\n\nAdds a new point to count the elapsed time. It will count from the last 'add' call or Timify creation in case of the first 'add'.\n\nYou can supply a label that will summarize all the ones with the same label\n\nThe output of this method will be the time elapsed in seconds (float).\n\nExamples:\n\n```ruby\nt=Timify.new :example\nt.add; run_sqls; t.add :database\nt.add\n#some processes\nt.add\n#some processes\nsend_email_alert(t.totals[:message]) if t.add \u003e 0.2\n#some processes\ndo_log(t.totals[:message]) if t.add \u003e 0.5\n```\n\n### totals\n\nReturns all data for this instance\n\nIn case json parameter supplied as true, the output will be in json format instead of a hash.\n\nThe output hash contains:\n\n    name: (String) name given for this instance'\n\n    total_time: (float) total elapsed time from initialization to last 'add' call\n\n    started: (Time)\n\n    finished: (Time)\n\n    message: (String) a printable friendly message giving all information\n\n    locations, labels, ranges: (Hash) the resultant hash contains:\n\n        secs: (float) number of seconds\n\n        percent: (integer) percentage in reference to the total time\n\n        count: (integer) number of times\n\n    locations: (Hash) All summary data by location where was called\n\n    labels: (Hash) All summary data by label given on 'add' method\n\n    ranges: (Hash) All summary data by ranges where was called, from last 'add' call to current 'add' call\n\n\nExample of output:\n```ruby\n{  :name=\u003e:add_customer_wrong, \n   :total_time=\u003e4.461446, \n   :started=\u003e2017-11-06 16:10:53 +0000, \n   :finished=\u003e2017-11-06 16:10:57 +0000, \n   :locations=\u003e{\n      \"/add_customer.rb:509\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:529\"=\u003e{:secs=\u003e0.008001, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:532\"=\u003e{:secs=\u003e0.212021, :percent=\u003e5, :count=\u003e1}, \n\t  \"/add_customer.rb:569\"=\u003e{:secs=\u003e0.006001, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:581\"=\u003e{:secs=\u003e0.446045, :percent=\u003e10, :count=\u003e1}, \n\t  \"/add_customer.rb:583\"=\u003e{:secs=\u003e3.789378, :percent=\u003e85, :count=\u003e1}, \n\t  \"/add_customer.rb:585\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:587\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:595\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:603\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:612\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:617\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}\n\t}, \n\t:labels=\u003e{\n\t\t:database_access=\u003e{:secs=\u003e4,447444, :percent=\u003e99, :count=\u003e3},\n\t\t:checkouts=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e2},\n\t}, \n\t:ranges=\u003e{\n\t  \"/add_customer.rb:509 - /add_customer.rb:529\"=\u003e{:secs=\u003e0.008001, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:529 - /add_customer.rb:532\"=\u003e{:secs=\u003e0.212021, :percent=\u003e5, :count=\u003e1}, \n\t  \"/add_customer.rb:532 - /add_customer.rb:569\"=\u003e{:secs=\u003e0.006001, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:569 - /add_customer.rb:581\"=\u003e{:secs=\u003e0.446045, :percent=\u003e10, :count=\u003e1}, \n\t  \"/add_customer.rb:581 - /add_customer.rb:583\"=\u003e{:secs=\u003e3.789378, :percent=\u003e85, :count=\u003e1}, \n\t  \"/add_customer.rb:583 - /add_customer.rb:585\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:585 - /add_customer.rb:587\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:587 - /add_customer.rb:595\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:595 - /add_customer.rb:603\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:603 - /add_customer.rb:612\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}, \n\t  \"/add_customer.rb:612 - /add_customer.rb:617\"=\u003e{:secs=\u003e0.0, :percent=\u003e0, :count=\u003e1}\n\t}, \n\t:message=\u003e\"\n\t\n\t\tTotal time \u003cadd_customer_wrong\u003e:4.46\n\t\tTotal time by location:\n\t\t\t/add_customer.rb:509: 0.0 (0%) #1\n\t\t\t/add_customer.rb:529: 0.01 (0%) #1\n\t\t\t/add_customer.rb:532: 0.21 (5%) #1\n\t\t\t/add_customer.rb:569: 0.01 (0%) #1\n\t\t\t/add_customer.rb:581: 0.45 (10%) #1\n\t\t\t/add_customer.rb:583: 3.79 (85%) #1\n\t\t\t/add_customer.rb:585: 0.0 (0%) #1\n\t\t\t/add_customer.rb:587: 0.0 (0%) #1\n\t\t\t/add_customer.rb:595: 0.0 (0%) #1\n\t\t\t/add_customer.rb:603: 0.0 (0%) #1\n\t\t\t/add_customer.rb:612: 0.0 (0%) #1\n\t\t\t/add_customer.rb:617: 0.0 (0%) #1\n\t\tTotal time by label:\n\t\t\tdatabase_access: 4.45 (99%) #3\n\t\t\tcheckouts: 0.0 (0%) #2\n\t\tTotal time by range:\n\t\t\t/add_customer.rb:509 - /add_customer.rb:529: 0.01 (0%) #1\n\t\t\t/add_customer.rb:529 - /add_customer.rb:532: 0.21 (5%) #1\n\t\t\t/add_customer.rb:532 - /add_customer.rb:569: 0.01 (0%) #1\n\t\t\t/add_customer.rb:569 - /add_customer.rb:581: 0.45 (10%) #1\n\t\t\t/add_customer.rb:581 - /add_customer.rb:583: 3.79 (85%) #1\n\t\t\t/add_customer.rb:583 - /add_customer.rb:585: 0.0 (0%) #1\n\t\t\t/add_customer.rb:585 - /add_customer.rb:587: 0.0 (0%) #1\n\t\t\t/add_customer.rb:587 - /add_customer.rb:595: 0.0 (0%) #1\n\t\t\t/add_customer.rb:595 - /add_customer.rb:603: 0.0 (0%) #1\n\t\t\t/add_customer.rb:603 - /add_customer.rb:612: 0.0 (0%) #1\n\t\t\t/add_customer.rb:612 - /add_customer.rb:617: 0.0 (0%) #1\n\t\"\n}\n```\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/marioruiz/timify.\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%2Fmarioruiz%2Ftimify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarioruiz%2Ftimify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarioruiz%2Ftimify/lists"}