Skip to content

Commit

Permalink
add hooks parameter to vernier
Browse files Browse the repository at this point in the history
  • Loading branch information
lHydra committed May 18, 2024
1 parent 6575956 commit 424f1af
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## master (unreleased)

- Vernier: Add hooks configuration parameter. ([@lHydra][])

Now you can add more insights to the resulting report by adding event markers from Active Support Notifications.
To do this, specify the `TEST_VERNIER_HOOKS=rails` env var or set it through `Vernier` configuration:

```ruby
TestProf::Vernier.configure do |config|
config.hooks = :rails
end
```

## 1.3.3 (2024-04-19)

- Fix MemProf bugs. ([@palkan][])
Expand Down Expand Up @@ -390,3 +401,4 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
[@Vankiru]: https://github.com/Vankiru
[@uzushino]: https://github.com/uzushino
[@lioneldebauge]: https://github.com/lioneldebauge
[@lHydra]: https://github.com/lHydra
19 changes: 19 additions & 0 deletions docs/profilers/ruby_profilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ You can also profile your application boot process:
TEST_VERNIER=boot bundle exec rspec ./spec/some_spec.rb
```

### Add markers from Active Support Notifications

You can add more insights to the resulting report by adding event markers from Active Support Notifications:

```sh
TEST_VERNIER=1 TEST_VERNIER_HOOKS=rails bundle exec rake test

# or for RSpec
TEST_VERNIER=1 TEST_VERNIER_HOOKS=rails bundle exec rspec ...
```

Or you can set the hooks parameter through the `Vernier` configuration:

```ruby
TestProf::Vernier.configure do |config|
config.hooks = :rails
end
```

## RubyProf

Easily integrate the power of [ruby-prof](https://github.com/ruby-prof/ruby-prof) into your test suite.
Expand Down
4 changes: 3 additions & 1 deletion lib/test_prof/vernier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ module TestProf
module Vernier
# Vernier configuration
class Configuration
attr_accessor :mode, :target, :interval
attr_accessor :mode, :target, :interval, :hooks

def initialize
@mode = ENV.fetch("TEST_VERNIER_MODE", :wall).to_sym
@target = (ENV["TEST_VERNIER"] == "boot") ? :boot : :suite

sample_interval = ENV["TEST_VERNIER_INTERVAL"].to_i
@interval = (sample_interval > 0) ? sample_interval : nil
@hooks = (ENV["TEST_VERNIER_HOOKS"] == "rails") ? :rails : nil
end

def boot?
Expand Down Expand Up @@ -82,6 +83,7 @@ def profile(name = nil)
options = {}

options[:interval] = config.interval if config.interval
options[:hooks] = config.hooks if config.hooks

if block_given?
options[:mode] = config.mode
Expand Down

0 comments on commit 424f1af

Please sign in to comment.