-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
require 'ripper'
require 'parser/current'
require 'benchmark/ips'
script = <<~EOM
def lol
puts "lol"
end
EOM
Benchmark.ips do |x|
x.report("ripper ") { Ripper.new(script).tap(&:parse).error? }
x.report("whitequark") { Parser::CurrentRuby.parse(script) }
x.compare!
end
Warming up --------------------------------------
ripper
9.624k i/100ms
whitequark 717.000 i/100ms
Calculating -------------------------------------
ripper 94.945k (± 3.5%) i/s - 481.200k in 5.074242s
whitequark 7.489k (± 3.0%) i/s - 38.001k in 5.079192s
Comparison:
ripper : 94945.0 i/s
whitequark: 7488.6 i/s - 12.68x (± 0.00) slower
Upsides:
- WAAAAY faster. Probably meaningfully faster.
- Ripper#error? Looks like it's available in all currently non EOL ruby versions (tested 2.5 and 2.7)
Downside:
- I can't find out which error was raised in parsing directly from ripper the same way I can with whitequark (parser gem).
I could use ripper purely for speed, and keep the whitequark gem in there for detecting which syntax error was raised for the short term.
Metadata
Metadata
Assignees
Labels
No labels