stackprof
Ruby Tests Profiling Toolbox
Our great sponsors
stackprof | Ruby Tests Profiling Toolbox | |
---|---|---|
6 | 7 | |
2,043 | 1,790 | |
- | 1.0% | |
5.7 | 7.5 | |
2 months ago | 8 days ago | |
Ruby | Ruby | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
stackprof
-
A Trick For Reading Flamegraphs
stackprof can be used alone/by itself to generate flamegraphs for arbitrary Ruby code.
-
Why do my requests take so much time to complete when View and ActiveRecord are finishing fast?
I’d use something like stackprof ( https://github.com/tmm1/stackprof ) to see where the time is going. If you already have suspicions you can use it to get information about a specific method / few lines of Ruby but there’s also a rack middleware.
-
Ok y’all. How can we get this kind of real-time memory profiling in Ruby? Does it already exist? Is anyone working on this?
stackprof
-
Optimizing your tests in 5 steps
Other profilers, such as stackprof, trace everything that’s happening by line. These types of profilers usually need some instrumentation to be configured, as shown below:
-
Is there a more efficient way to do these permutation calculations?
Either https://github.com/tmm1/stackprof for cpu or https://github.com/SamSaffron/memory_profiler for memory. In practice profiling and removing allocations also gives a large perf boost.
-
Automatically benchmark methods used within Rails
At first, I tried to benchmark the method using the benchmark library. (The profiler uses stackprof)
Ruby Tests Profiling Toolbox
-
Must-have gems for mature Rails
gem "test-prof" - https://github.com/test-prof/test-prof | Toolkit for inspecting and optimising your test-suite, a must-have.
-
Measuring load time on fixtures
You might be able to do something with https://test-prof.evilmartians.io, but I'm not sure it has anything specific to fixtures out of the box. Maybe using the event profiler on sql.active_record events would be close enough. In the limit, you could wire together your own ActiveSupport::Notifications.instrument around the relevant blocks + an ActiveSupport::Notifications.subscribe to that event so as to log the relevant information. Docs: https://api.rubyonrails.org/classes/ActiveSupport/Notifications.html
-
How to optimize factory creation.
To have a better vision of what objects are created in our spec file we can use test-prof, a powerful gem that provides a collection of different tools to analyse your test suite performance. One of this tool is really useful to identify a factory cascade, let’s introduce factory profiler.
-
A Trick For Reading Flamegraphs
TestProf can be used to get flamegraphs for Ruby test suites.
- How to improve a test suit made with Rspec, Capybara, FactoryBot and Siteprism
-
Does pytest break a lot of coding rules?
Rspec has spec_helper.rb.
-
Learning resources to broaden the knowledge
I also love the test-prof documentation, there's a lot of good ideas on how to improve test performance.
What are some alternatives?
rbtrace - like strace, but for ruby code
DuckRails - Development tool to mock API endpoints quickly and easily (docker image available)
memray - Memray is a memory profiler for Python
Spinach - Spinach is a BDD framework on top of Gherkin.
speedscope - 🔬 A fast, interactive web-based viewer for performance profiles.
minitest - minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking.
MemoryProfiler - memory_profiler for ruby
timecop - A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
Rbenchmarker - Automatically log benchmarks for all methods
factory_bot - A library for setting up Ruby objects as test data.
rails_panel - Chrome extension for Rails development
faker - A library for generating fake data such as names, addresses, and phone numbers.