Skip to content

Commit 4d3610f

Browse files
committed
Tiny structural improvement of README.
Add an example for `mode: :object` in the very top.
1 parent 52d1df6 commit 4d3610f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,38 @@ Inspired heavily by [gperftools](https://code.google.com/p/gperftools/), and wri
1616
In your Gemfile add:
1717

1818
```ruby
19-
gem 'stackprof'
19+
gem "stackprof"
2020
```
2121

2222
Then run `$ bundle install`. Alternatively you can run `$ gem install stackprof`.
2323

2424

2525
### Run
2626

27-
in ruby:
27+
The `StackProf.run` method accepts a block with your code to be profiled.
2828

2929
``` ruby
30-
StackProf.run(mode: :cpu, out: 'tmp/stackprof-cpu-myapp.dump') do
30+
StackProf.run(mode: :cpu, out: "tmp/stackprof-cpu-myapp.dump") do
3131
#...
3232
end
3333
```
3434

35-
via rack:
35+
The `:out` option specifies where the sample data is written to.
36+
37+
#### Mode
38+
39+
When profiling a less complex code chunk it might be more helpful to switch from `:cpu` mode to `:object`. This is
40+
advisable when your `:cpu` run doesn't produce any samples.
41+
42+
``` ruby
43+
StackProf.run(mode: :object, out: "tmp/stackprof-cpu-myapp.dump") do
44+
#...
45+
end
46+
```
47+
48+
#### Rack
49+
50+
In a Rack application, `stackprof` provides a convenient middleware.
3651

3752
``` ruby
3853
use StackProf::Middleware, enabled: true,
@@ -41,7 +56,9 @@ use StackProf::Middleware, enabled: true,
4156
save_every: 5
4257
```
4358

44-
reporting:
59+
### Reporting
60+
61+
The file produced by the profiler can be visualized to a human-readable form by using the `stackprof` CLI command.
4562

4663
```
4764
$ stackprof tmp/stackprof-cpu-*.dump --text --limit 1

0 commit comments

Comments
 (0)