When experimenting with Opal a couple of months ago, I threw together a microbenchmark on top of everyone's favourite recursive
fibonacci algorithms using Benchmark.js in an attempt to answer this question.
A few runs on my laptop quickly demonstrated a performance loss of (on average) two orders of magnitude for the Opal/Ruby implementations.
Opal#factorial x 270,439 ops/sec ±8.06% (93 runs sampled)
JS#factorial x 23,964,240 ops/sec ±1.28% (94 runs sampled)
Opal#fibonacci x 10,020 ops/sec ±2.78% (89 runs sampled)
JS#fibonacci x 434,727 ops/sec ±10.29% (80 runs sampled)
Here's the code I used:
Ruby's backtick operator (or the equivalent
Lets take a look at what this does to our benchmarks.
RubyWithInlineJS#factorial x 24,201,484 ops/sec ±1.22% (94 runs sampled)
RubyWithInlineJS#fibonacci x 524,180 ops/sec ±1.13% (91 runs sampled)
If you want to run these benchmarks yourself, take a look at the Performance Benchmarks section of the Redson README.