{"id":19199968,"url":"https://github.com/fusic/estackprof","last_synced_at":"2025-05-09T01:28:39.757Z","repository":{"id":56844872,"uuid":"402235838","full_name":"fusic/estackprof","owner":"fusic","description":"Estackprof is a wrapper to make it easier to use Stackprof in your rack application.","archived":false,"fork":false,"pushed_at":"2021-09-27T09:51:22.000Z","size":65,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T00:11:57.067Z","etag":null,"topics":["performance","profile","ruby","tool"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/estackprof","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fusic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-02T00:02:17.000Z","updated_at":"2022-12-15T21:07:57.000Z","dependencies_parsed_at":"2022-09-09T21:11:07.377Z","dependency_job_id":null,"html_url":"https://github.com/fusic/estackprof","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Festackprof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Festackprof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Festackprof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusic%2Festackprof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fusic","download_url":"https://codeload.github.com/fusic/estackprof/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253173603,"owners_count":21865718,"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":["performance","profile","ruby","tool"],"created_at":"2024-11-09T12:29:46.041Z","updated_at":"2025-05-09T01:28:39.731Z","avatar_url":"https://github.com/fusic.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Estackprof\n\nEstackprof is a wrapper to make it easier to use [Stackprof](https://github.com/tmm1/stackprof) in your rack application.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'estackprof'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install estackprof\n\n## Usage\n\n### Profiling\n\nAdd the following code to your rack application to enable the rack middleware.\n`Estackprof::Middleware` supports the same options as `StackProf::Middleware`.\n\n```ruby\nrequire 'estackprof'\n\nuse Estackprof::Middleware\n\n# ...your rack application\n```\n\n### Reporting\n\nUse the CLI to report.\n\n```sh\n# Report the top 3 frames\n$ estackprof top -l 3\n==================================\n  Mode: cpu(1000)\n  Samples: 516 (0.00% miss rate)\n  GC: 77 (14.92%)\n==================================\n     TOTAL    (pct)     SAMPLES    (pct)     FRAME\n       434  (84.1%)         434  (84.1%)     Object#bubble_sort(example/app.rb:9)\n        45   (8.7%)          45   (8.7%)     (sweeping)\n        31   (6.0%)          31   (6.0%)     (marking)\n\n# Report the top 3 cumlative frames\n$ estackprof top -l 3 -c\n==================================\n  Mode: cpu(1000)\n  Samples: 516 (0.00% miss rate)\n  GC: 77 (14.92%)\n==================================\n     TOTAL    (pct)     SAMPLES    (pct)     FRAME\n       439  (85.1%)           0   (0.0%)     Rack::MethodOverride#call(vendor/bundle/ruby/3.0.0/gems/rack-2.2.3/lib/rack/method_override.rb:15)\n       439  (85.1%)           0   (0.0%)     Sinatra::ExtendedRack#call(vendor/bundle/ruby/3.0.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:215)\n       439  (85.1%)           0   (0.0%)     Sinatra::Wrapper#call(vendor/bundle/ruby/3.0.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1990)\n\n# Report the top frames filtered by patten(file name).\n$ estackprof top -p app.rb\n==================================\n  Mode: cpu(1000)\n  Samples: 516 (0.00% miss rate)\n  GC: 77 (14.92%)\n==================================\n     TOTAL    (pct)     SAMPLES    (pct)     FRAME\n       434  (84.1%)         434  (84.1%)     Object#bubble_sort(example/app.rb:9)\n       438  (84.9%)           0   (0.0%)     block in \u003cmain\u003e(example/app.rb:23)\n\n# Report the top frames filtered by patten(method name).\n$ estackprof top -p bubble\n==================================\n  Mode: cpu(1000)\n  Samples: 516 (0.00% miss rate)\n  GC: 77 (14.92%)\n==================================\n     TOTAL    (pct)     SAMPLES    (pct)     FRAME\n       434  (84.1%)         434  (84.1%)     Object#bubble_sort(example/app.rb:9)\n\n# Report the list in the specified file.\n$ estackprof list -f app.rb\n                                  |     1  | # frozen_string_literal: true\n                                  |     2  | \n                                  |     3  | require 'sinatra'\n                                  |     4  | require 'json'\n                                  |     5  | require 'estackprof'\n                                  |     6  | \n                                  |     7  | use Estackprof::Middleware\n                                  |     8  | \n                                  |     9  | def bubble_sort(array)\n                                  |    10  |   ary = array.dup\n                                  |    11  |   pos_max = ary.size - 1\n                                  |    12  | \n  434   (84.1%)                   |    13  |   (0...pos_max).each do |n|\n  433   (83.9%)                   |    14  |     (0...(pos_max - n)).each do |ix|\n                                  |    15  |       iy = ix + 1\n  139   (26.9%) /   139  (26.9%)  |    16  |       ary[ix], ary[iy] = ary[iy], ary[ix] if ary[ix] \u003e ary[iy]\n  294   (57.0%) /   294  (57.0%)  |    17  |     end\n    1    (0.2%) /     1   (0.2%)  |    18  |   end\n                                  |    19  | \n                                  |    20  |   ary\n                                  |    21  | end\n                                  |    22  | \n                                  |    23  | get '/' do\n                                  |    24  |   array = Array.new(1000) { rand(10_000) }\n  438   (84.9%)                   |    25  |   bubble_sort(array).to_s\n                                  |    26  | end\n\n# Report the list in the specified method.\n$ estackprof list -m bubble\nObject#bubble_sort (/estackprof/example/app.rb:9)\n  samples:   434 self (84.1%)  /    434 total (84.1%)\n  callers:\n     867  (  199.8%)  Range#each\n     434  (  100.0%)  block in \u003cmain\u003e\n  callees (0 total):\n     867  (    Inf%)  Range#each\n  code:\n                                  |     9  | def bubble_sort(array)\n                                  |    10  |   ary = array.dup\n                                  |    11  |   pos_max = ary.size - 1\n                                  |    12  | \n  434   (84.1%)                   |    13  |   (0...pos_max).each do |n|\n  433   (83.9%)                   |    14  |     (0...(pos_max - n)).each do |ix|\n                                  |    15  |       iy = ix + 1\n  139   (26.9%) /   139  (26.9%)  |    16  |       ary[ix], ary[iy] = ary[iy], ary[ix] if ary[ix] \u003e ary[iy]\n  294   (57.0%) /   294  (57.0%)  |    17  |     end\n    1    (0.2%) /     1   (0.2%)  |    18  |   end\n                                  |    19  |\n\n# Display the flamegraph\n$ estackprof flamegraph\n#=\u003e Open flamegraph in your browser.\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## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/fusic/estackprof.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusic%2Festackprof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusic%2Festackprof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusic%2Festackprof/lists"}