{"id":20926506,"url":"https://github.com/lukes/profiling","last_synced_at":"2026-03-05T08:03:02.291Z","repository":{"id":52915322,"uuid":"130154878","full_name":"lukes/profiling","owner":"lukes","description":"Non-discriminatory profiling of Ruby code leveraging the ruby-prof gem","archived":false,"fork":false,"pushed_at":"2021-04-14T03:43:26.000Z","size":199,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-29T07:50:46.106Z","etag":null,"topics":["code","gem","memory","optimisation","optimization","profiler","profiling","ruby"],"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/lukes.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":"2018-04-19T03:36:40.000Z","updated_at":"2021-04-14T03:43:23.000Z","dependencies_parsed_at":"2022-08-20T16:00:21.675Z","dependency_job_id":null,"html_url":"https://github.com/lukes/profiling","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukes%2Fprofiling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukes%2Fprofiling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukes%2Fprofiling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukes%2Fprofiling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukes","download_url":"https://codeload.github.com/lukes/profiling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253993739,"owners_count":21996370,"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":["code","gem","memory","optimisation","optimization","profiler","profiling","ruby"],"created_at":"2024-11-18T20:39:20.105Z","updated_at":"2026-03-05T08:02:57.244Z","avatar_url":"https://github.com/lukes.png","language":"Ruby","readme":"![alt ruby_silhouette](https://raw.githubusercontent.com/lukes/profiling/master/img/ruby.png)\n\n# Profiling\n\nNon-discriminatory profiling for your MRI Ruby code. This gem is a small wrapper around the [ruby-prof](https://github.com/ruby-prof/ruby-prof) gem, which is its only dependency. It lets you do simple but powerful profiling of your friend's bad code.\n\n[![Gem Version](https://badge.fury.io/rb/profiling.svg)](https://badge.fury.io/rb/profiling)\n[![CircleCI](https://circleci.com/gh/lukes/profiling/tree/master.svg?style=shield)](https://circleci.com/gh/lukes/profiling/tree/master)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'profiling', \"~\u003e 4.0\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install profiling\n\n## Getting Started\n\nProfile slow code from your friend or colleague like this:\n\n```ruby\nProfiler.run do\n  # Slow code here...\nend\n```\n\nThe next time you call the code it will be profiled and three files will be written into a directory called `profiling`.\n\n### Files Generated\n\n| File | Description |\n| ------------- | ------------- |\n| `graph.html` | Drill down into the call tree to see where the time is spent |\n| `stack.html` | See the profiled code as a nested stack |\n| `flat.txt` | List of all functions called, the time spent in each and the number of calls made to that function |\n\n### Is it Fast?\n\nNo, no it's not. It's really slow. For especially gnarly, deeply nested code you will want to get up and get a coffee. This gem wraps [ruby-prof](https://github.com/ruby-prof/ruby-prof) which is partly written in C, so it's as fast as it can be.\n## Options\n\nUse the `configure` method to set some options:\n\n```ruby\nProfiler.configure({\n  dir: '/tmp/my-dir',\n  exclude_gems: true,\n  exclude_standard_lib: true\n})\n```\n\n| Option | Description | Default |\n| ------ | --------|------------ |\n| `dir` | Directory the files will be created in (can be relative or absolute) | `\"profiling\"` |\n| `exclude_gems` | Exclude ruby gems from the results | `false` |\n| `exclude_standard_lib` | Exclude ruby standard library from results | `false` |\n\n## Rails Initializer\n\nThis initializer is recommended if you're planning to profile in Rails:\n\n```ruby\n# config/initializer/profiling.rb\nProfiler.configure({\n  dir: Rails.root.join('tmp/profiling')\n})\n```\n\n## Conditional Profiling\n\nPass an argument `if:` to enable or disable profiling at run time:\n\n```ruby\nProfiler.run(if: user.is_admin?) do\n  # Slow code here...\nend\n```\n\n## Labels\n\nLabels translate to sub directories that the files will be generated in. This is handy for profiling multiple things at once, preserving files between runs, or grouping profiling results logically.\n\n```ruby\nProfiler.run(\"some-label\") do\n  # Slow code here...\nend\n```\n\n### Preserving files between runs\n\nKeep old files by adding the current time in the label so new files are generated with each run:\n\n```ruby\nProfiler.run(\"some-label-#{Time.now.to_i}\") do\n  # Slow code here...\nend\n```\n\n### Organizing\n\nUse `/` in your labels to group profiling results together in directories:\n\n```ruby\nProfiler.run(\"post/create\") do\n  # Slow code here...\nend\n\nProfiler.run(\"post/update\") do\n  # Slow code here...\nend\n```\n\n## Contributing\n\nBug reports and pull requests are welcome. Pull requests with passing tests are even better.\n\nTo run the test suite:\n\n    bundle exec rspec\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukes%2Fprofiling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukes%2Fprofiling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukes%2Fprofiling/lists"}