Skip to content

Commit

Permalink
Merge pull request #68 from joshuay03/update-readme
Browse files Browse the repository at this point in the history
Add start/stop and options to README
  • Loading branch information
jhawthorn committed Jun 4, 2024
2 parents 4eb6087 + 9d3265c commit 32017d3
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Next-generation Ruby 3.2.1+ sampling profiler. Tracks multiple threads, GVL acti

[Livestreamed demo: Pairin' with Aaron (YouTube)](https://www.youtube.com/watch?v=9nvX3OHykGQ#t=27m43)

Sidekiq jobs from Mastodon (time, threded)
Sidekiq jobs from Mastodon (time, threaded)
: https://share.firefox.dev/44jZRf3

Puma web requests from Mastodon (time, threded)
Puma web requests from Mastodon (time, threaded)
: https://share.firefox.dev/48FOTnF

Rails benchmark - lobste.rs (time)
Expand Down Expand Up @@ -50,16 +50,34 @@ starting profiler with interval 500
written to /tmp/profile20240328-82441-gkzffc.vernier.json
```

### Block of code
#### Block of code

``` ruby
Vernier.run(out: "time_profile.json") do
Vernier.profile(out: "time_profile.json") do
some_slow_method
end
```

Alternatively you can use the aliases `Vernier.run` and `Vernier.trace`.

#### Start and stop

```ruby
Vernier.start_profile(out: "time_profile.json")

some_slow_method

# some other file

some_other_slow_method

Vernier.stop_profile
```

### Retained memory

#### Block of code

Record a flamegraph of all **retained** allocations from loading `irb`.

```
Expand All @@ -68,6 +86,14 @@ ruby -r vernier -e 'Vernier.trace_retained(out: "irb_profile.json") { require "i

Retained-memory flamegraphs must be interpreted a little differently than a typical profiling flamegraph. In a retained-memory flamegraph, the x-axis represents a proportion of memory in bytes, _not time or samples_ The topmost boxes on the y-axis represent the retained objects, with their stacktrace below; their width represents the percentage of overall retained memory each object occupies.

### Options

Option | Description
:- | :-
`mode` | The sampling mode to use. One of `:wall`, `:retained` or `:custom`. Default is `:wall`.
`out` | The file to write the profile to.
`gc` | Initiate a full and immediate garbage collection cycle before profiling. Only available in `:retained` mode.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down

0 comments on commit 32017d3

Please sign in to comment.