Skip to content

Commit

Permalink
Add how to profile Lrama
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Oct 9, 2023
1 parent f0bf972 commit b1adbe4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,44 @@ $ rake build:racc_parser
`new_parser.rb` is generated from `parser.y` by Racc.
Run the rake command when you update `parser.y` then commit changes of both files.

### Profiling Lrama

#### 1. Create parse.tmp.y in ruby/ruby

```shell
$ ruby tool/id2token.rb parse.y > parse.tmp.y
$ cp parse.tmp.y dir/lrama/tmp
```

#### 2. Enable Profiler

```diff
diff --git a/exe/lrama b/exe/lrama
index ba5fb06..2497178 100755
--- a/exe/lrama
+++ b/exe/lrama
@@ -3,4 +3,6 @@
$LOAD_PATH << File.join(__dir__, "../lib")
require "lrama"

-Lrama::Command.new.run(ARGV.dup)
+Lrama::Report::Profile.report_profile do
+ Lrama::Command.new.run(ARGV.dup)
+end
```

#### 3. Run Lrama

```shell
$ exe/lrama -d -o parse.tmp.c -h tmp/parse.tmp.y
```

#### 4. Generate Flamegraph

```shell
$ stackprof --d3-flamegraph tmp/stackprof-cpu-myapp.dump > tmp/flamegraph.html
```

### Build Ruby

1. Install Lrama
Expand Down

0 comments on commit b1adbe4

Please sign in to comment.