{"id":17557755,"url":"https://github.com/splattael/hotch","last_synced_at":"2025-04-16T03:49:54.290Z","repository":{"id":25361053,"uuid":"28788854","full_name":"splattael/hotch","owner":"splattael","description":"Profile helper","archived":false,"fork":false,"pushed_at":"2022-12-12T12:17:11.000Z","size":153,"stargazers_count":28,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T04:51:10.445Z","etag":null,"topics":["memory-profiler","profiler","ruby"],"latest_commit_sha":null,"homepage":null,"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/splattael.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":"2015-01-04T23:01:43.000Z","updated_at":"2022-12-14T22:30:33.000Z","dependencies_parsed_at":"2023-01-14T02:36:51.476Z","dependency_job_id":null,"html_url":"https://github.com/splattael/hotch","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splattael%2Fhotch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splattael%2Fhotch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splattael%2Fhotch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splattael%2Fhotch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splattael","download_url":"https://codeload.github.com/splattael/hotch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249136009,"owners_count":21218388,"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":["memory-profiler","profiler","ruby"],"created_at":"2024-10-21T09:24:13.641Z","updated_at":"2025-04-16T03:49:54.267Z","avatar_url":"https://github.com/splattael.png","language":"Ruby","readme":"# Hotch\n\n[![Gem Version](https://img.shields.io/gem/v/hotch.svg)](https://rubygems.org/gems/hotch)\n[![Source code](https://img.shields.io/badge/code-GitHub-blue.svg)](https://github.com/splattael/hotch)\n\nProfile helper\n\n## What?\n\n### Callstack profiler\n\n* Wraps your program run with [stackprof](https://rubygems.org/gems/stackprof)\n* Dumps profile results\n* Converts a profile dump using [graphviz](http://www.graphviz.org/) (dot) to SVG\n* Optionally shows the call-stack graph after program exit\n\n### Memory profiler\n\n* Traces memory allocation using [allocation_tracer](https://rubygems.org/gems/allocation_tracer)\n* Prints the results formatted and sorted by object count\n\n## Example\n\n### Callstack profiler\n\nFrom [dry-validation](https://github.com/dry-rb/dry-validation) [benchmarks/profile_schema_call_valid.rb](https://github.com/dry-rb/dry-validation/blob/3d090eeafac9d1c31fdc3e054f8fd5ec900e12f9/benchmarks/profile_schema_call_valid.rb):\n\n![dry-validation](images/dry-validation.profile_schema_call_valid.png?raw=true \"benchmarks/profile_schema_call_valid.rb\")\n\n### Memory profiler\n\n```\n                        filename     type count old_count total_age min_age max_age total_memsize\n                    inline.rb:28  T_IMEMO     1         0         0       0       0             0\ndry/struct/class_interface.rb:74  T_IMEMO     1         0         0       0       0             0\ndry/struct/class_interface.rb:77  T_IMEMO     1         0         0       0       0             0\n       dry/types/decorator.rb:28  T_IMEMO     1         0         0       0       0             0\n     dry/types/hash/schema.rb:96  T_IMEMO     2         0         0       0       0             0\n     dry/types/hash/schema.rb:52  T_IMEMO     2         0         0       0       0             0\n                    inline.rb:27 T_STRING  1000         0         0       0       0             0\n                    inline.rb:28   T_HASH  1000         0         0       0       0             0\n                    inline.rb:26   T_HASH  1000         0         0       0       0             0\n     dry/types/hash/schema.rb:92   T_HASH  2000         0         0       0       0             0\n     dry/types/hash/schema.rb:60   T_HASH  2000         0         0       0       0             0\n             dry/logic/rule.rb:0  T_ARRAY  2000         0         0       0       0             0\n            dry/logic/rule.rb:47 T_OBJECT  2000         0         0       0       0             0\n      dry/types/definition.rb:59 T_OBJECT  2000         0         0       0       0             0\ndry/struct/class_interface.rb:77 T_OBJECT  2000         0         0       0       0             0\n     dry/types/constrained.rb:20   T_DATA  4000         0         0       0       0             0\n     dry/types/constrained.rb:27  T_ARRAY  4000         0         0       0       0             0\n            dry/logic/rule.rb:47  T_ARRAY  4000         0         0       0       0             0\n            dry/logic/rule.rb:47   T_DATA  4000         0         0       0       0             0\n      dry/types/definition.rb:51  T_ARRAY  4000         0         0       0       0             0\n     dry/types/hash/schema.rb:92  T_ARRAY  6000         0         0       0       0             0\n                dry/struct.rb:16 T_STRING  6000         0         0       0       0             0\n                           TOTAL          47008         0         0       0       0             0\n```\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hotch', '~\u003e 0.7.0'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install hotch\n\n## Usage\n\n### Profile complete program\n\n    $ ruby -rhotch/run my_program.rb\n    Profile SVG: /tmp/hotch.my_program20150104-17330-18t4171/profile.svg\n    $ view /tmp/hotch.my_program20150104-17330-18t4171/profile.svg\n\n### Profile blocks in your program\n\n```ruby\nrequire 'hotch'\n\ndef expensive_method\n  # ...\nend\n\nHotch() do\n  1000.times do\n    expensive_method\n  end\nend\n\nHotch(aggregate: false) do\n  1000.times do\n    # this run is not aggregated\n  end\nend\n\nHotch() do\n  1000.times do\n    # aggregated again\n  end\nend\n```\n\n### Auto-view\n\nSet envvar `HOTCH_VIEWER` to enable auto-view after profiling.\n\n    $ export HOTCH_VIEWER=eog # use Gnome viewer\n\n### Filter\n\nSet envvar `HOTCH_FILTER` to (regexp) filter frames by its name.\n\n    $ export HOTCH_FILTER=ROM\n    $ export HOTCH_FILTER=Bundler\n\n### Minitest integration\n\nLoad `hotch/minitest` in your `test/test_helper.rb` like this:\n\n```ruby\nrequire 'minitest/autorun'\nrequire 'hotch/minitest'\n\nHotch::Minitest.run\nHotch::Minitest.run(filter: /MyClass/)\nHotch::Minitest.run(options: \u003cstackprof options\u003e)\nHotch::Minitest.run(options: { limit: 200 })\n```\n\n### Memory profiler\n\nShell usage:\n\n    $ ruby -rhotch/memory/run my_program.rb\n\nRequire `hotch/memory` and use `Hotch.memory { ... }` as in:\n\n```ruby\nrequire \"bundler/setup\"\n\nrequire \"dry-types\"\nrequire \"dry-struct\"\nrequire \"hotch/memory\"\n\nmodule Types\n  class IntStruct \u003c Dry::Struct\n    include Dry::Types.module\n    constructor_type :strict\n    attribute :int, Strict::Int\n  end\n\n  class Success \u003c Dry::Struct\n    include Dry::Types.module\n    constructor_type :strict\n    attribute :string, Strict::String\n    attribute :sub, Types::IntStruct\n  end\nend\n\n# For more stable results the GC is disabled by default during runs.\nHotch.memory do\n  1000.times do\n    Types::Success.new(\n      :string =\u003e \"string\",\n      :sub =\u003e Types::IntStruct.new(:int =\u003e 1)\n    )\n  end\nend\n\n# In order to prevent disabling the GC during runs do:\nHotch.memory(disable_gc: false) do\n  # ...\nend\n\n# Disable aggregation between runs:\nHotch.memory(aggregate: false) do\n  # this run is not aggregated\nend\n```\n\n#### Inline reporting\n\nThis prints two ASCII tables showing the object alloctions two calls:\n\n```ruby\nputs Hotch::Memory.report(\"memory\") {\n  # ...\n}\n\nputs Hotch::Memory.report(\"another\") {\n  # ...\n}\n```\n\n### Minitest integration for the memory profiler\n\nLoad `hotch/memory/minitest` in your `test/test_helper.rb` like this:\n\n```ruby\nrequire 'minitest/autorun'\nrequire 'hotch/memory/minitest'\n\nHotch::Memory::Minitest.run\nHotch::Memory::Minitest.run(name: \"my name\")\nHotch::Memory::Minitest.run(disable_gc: false) # on by default\n```\n\n\n## Caveat\n\n### Using with bundler\n\nIf you use `hotch` in project managed by `bundler` you have to specify `hotch` in `Gemfile`.(see Installation section above)\n\n## Contributing\n\n1. Fork it ( https://github.com/splattael/hotch/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Release\n\nFollow these steps to release this gem:\n\n    # Increase version\n    edit lib/hotch/version.rb\n    edit README.md\n    # Commit\n    git commit -am \"Release vX.Y.Z\"\n    rake release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplattael%2Fhotch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplattael%2Fhotch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplattael%2Fhotch/lists"}