{"id":16656371,"url":"https://github.com/wnuqui/runtime_profiler","last_synced_at":"2025-04-09T18:21:10.590Z","repository":{"id":54509256,"uuid":"125716880","full_name":"wnuqui/runtime_profiler","owner":"wnuqui","description":"Runtime Profiler for Rails Applications","archived":false,"fork":false,"pushed_at":"2021-02-14T19:07:08.000Z","size":181,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T22:19:14.108Z","etag":null,"topics":["api","api-instrumentation","api-profiler","instrumentation","instrumenter","performance","profiling","profiling-library","rails","runtime-metrics","runtime-profiler"],"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/wnuqui.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":"2018-03-18T11:13:44.000Z","updated_at":"2024-01-12T17:59:15.000Z","dependencies_parsed_at":"2022-08-13T18:10:36.750Z","dependency_job_id":null,"html_url":"https://github.com/wnuqui/runtime_profiler","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fruntime_profiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fruntime_profiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fruntime_profiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnuqui%2Fruntime_profiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wnuqui","download_url":"https://codeload.github.com/wnuqui/runtime_profiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085453,"owners_count":21045164,"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":["api","api-instrumentation","api-profiler","instrumentation","instrumenter","performance","profiling","profiling-library","rails","runtime-metrics","runtime-profiler"],"created_at":"2024-10-12T09:57:10.159Z","updated_at":"2025-04-09T18:21:10.568Z","avatar_url":"https://github.com/wnuqui.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# runtime_profiler\n\n*A runtime profiler for Rails applications.*\n\nCheck which part of your Rails application is causing slow response time. **runtime_profiler** gives you an easy way to find performance problems by profiling an endpoint or a method in your Rails application.\n\n[![Build Status](https://wnuqui.semaphoreci.com/badges/runtime_profiler/branches/master.svg?style=shields)](https://wnuqui.semaphoreci.com/projects/runtime_profiler)\n\n## Table of contents\n\n- [Getting Started](#getting-started)\n  - [Installing](#installing)\n  - [Profiling](#profiling)\n    - [Structure](#structure)\n    - [Examples](#examples)\n  - [Viewing Profiling Result](#viewing-profiling-result)\n    - [view Options](#view-options)\n  - [Screenshot](#screenshot)\n  - [Configurations](#configurations)\n- [Development](#development)\n- [Contributing](#contributing)\n- [Acknowledgement](#acknowledgement)\n- [License](#license)\n\n## Getting Started\n\n### Installing\n\nAdd this line to your application's Gemfile:\n\n```ruby\n# In your Gemfile\ngroup :development, :test do\n  gem 'runtime_profiler'\nend\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install runtime_profiler\n\n### Profiling\n\n#### Structure\n\nTo profile a specific class (model, controller, etc), all you need to do is to wrap a line where the target class (or instance) is calling a method (entry point of profiling).\n\n```ruby\n# Profiles runtime of `ClassToProfile` class.\nRuntimeProfiler.profile!('description', [ClassToProfile]) {\n  # one line where `ClassToProfile` (or its instance) is calling a method\n}\n```\n\nSince the second argument of `.profile!` accepts array of classes, then you can provide all target classes that you want to profile.\n\n#### Examples\n\nYou can make a test that targets a particular endpoint (or even just a method) and use `RuntimeProfiler.profile!` method in the test.\n\n```ruby\nit 'updates user' do\n  # Profiles runtime of PUT /users/:id endpoint and\n  # specifically interested with the methods of `User` model.\n  RuntimeProfiler.profile!('updates user', [User]) {\n    patch :update, { id: user.id, name: 'Joe' }\n  }\n\n  expect(response.status).to eq(200)\nend\n```\n\nRun the test as usual and follow printed instructions after running.\n\nOr if you prefer writing just code snippet, then just wrap the snippet with `RuntimeProfiler.profile!` method:\n```ruby\n# Profiles runtime of `UserMailer` mailer.\nRuntimeProfiler.profile!('UserMailer', [UserMailer]) {\n  user = User.last\n  UserMailer.with(user: user).weekly_summary.deliver_now\n}\n```\n\n**Note:** The code (test or not) where `RuntimeProfiler.profile!` is used must be **free from any mocking/stubbing** since the goal is to check performance bottlenecks.\n\n### Viewing Profiling Result\n\nTo see profiling report, you can open the report in browser with JSON viewer report. Or you can run the following command:\n\n```bash\nbundle exec runtime_profiler view tmp/rp-124094-1608308786.json\n```\n\n#### view options\n\nHere are the command line options for `runtime_profiler view` command.\n\n```bash\n$ bundle exec runtime_profiler view --help\n\n  NAME:\n\n    view\n\n  SYNOPSIS:\n\n    runtime_profiler view \u003cprofile.report.json\u003e [options]\n\n  DESCRIPTION:\n\n    Display report in console given the JSON report file\n\n  OPTIONS:\n\n    --sort-by COLUMN\n        Sort by COLUMN. COLUMN can be \"max_runtime\", total_calls\" or \"total_runtime\". Default is \"max_runtime\".\n\n    --details TYPE\n        TYPE can be \"full\" or \"summary\". Default is \"summary\"\n\n    --only-sqls\n        Show only SQL queries. Default is false.\n\n    --only-methods\n        Show only methods. Default is false.\n\n    --runtime-above RUNTIME\n        RUNTIME is integer or float value in ms.\n\n    --calls-above CALLS\n        CALLS is integer value.\n\n    --rounding ROUNDING\n        ROUNDING is integer value. Used in rounding runtimes. Default is 4.\n```\n\n### Screenshot\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"rp_view_command.png\"\u003e\n\u003c/p\u003e\n\n### Configurations\n\nAll the configurable variables and their defaults are listed below. There is no one correct place where to put these configurations. It can be inside `config/initializers` folder of your Rails application. Or if you are using test to profile, it can be in the last part of `spec/spec_helper.rb`.\n```ruby\nRuntimeProfiler.output_path = File.join(Rails.root.to_s, 'tmp')\nRuntimeProfiler.profiled_constants = [User]\nRuntimeProfiler.profiled_paths = %w(app lib)\nRuntimeProfiler.profiled_sql_commands = %w(SELECT INSERT UPDATE DELETE)\n# Useful when you want to exclude in profiling specific method(s) from framework/library being used\nRuntimeProfiler.excepted_methods = [:attribute_type_decorations, :_validators, :defined_enums]\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 tags, 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/wnuqui/runtime_profiler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## Acknowledgement\n\nPart of this profiler is based from https://github.com/steventen/sql_tracker.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnuqui%2Fruntime_profiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwnuqui%2Fruntime_profiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnuqui%2Fruntime_profiler/lists"}