selfrefactor / rambda

Faster and smaller alternative to Ramda
https://selfrefactor.github.io/rambda
MIT License
1.65k stars 89 forks source link

ramBda curry is slower than ramda #603

Closed mohit61 closed 2 years ago

mohit61 commented 3 years ago

Hi,

In the benchmark result in Readme for curry, ramda is 28.86% slower than ramBda, but in my local benchmarking ramda is faster than ramBda

import * as R from 'ramda'
import {curry} from 'rambda'

const add = (a, b) => a + b;
const ramdaCurry = R.curry(add);
const ramBdaCurry = curry(add);

console.time('ramBda curry');
for (let i = 0; i < 1e8; i++) {
    ramBdaCurry(1)(2);
}
console.timeEnd('ramBda curry');

console.time('ramda curry');
for (let i = 0; i < 1e8; i++) {
    ramdaCurry(1)(2)
}
console.timeEnd('ramda curry');

Output:

ramBda curry: 10.358s
ramda curry: 8.028s

Could you please explain how your benchmarking is done?

selfrefactor commented 3 years ago

Benchmarking is done with benny library. The benchmarks can be started from from rambda-scripts repo. Unfortunately, there is lack of documentation of how to run the benchmarks.

It is no surprise that some Ramda methods are faster than Rambda - this is possible. Exact reason whey R.curry is slower are not known to me without looking at the code.

What I wrote in the other issue is that Rambda doesn't use helper method to apply currying- this is done inside the function itself. Rambda.curry is used internally only for methods with 3 inputs such as R.replace.

selfrefactor commented 2 years ago

From reading Ramda code, I'd say that main reason might be the check if input is R.__(placeholder). I am closing the issue, but feel free to comment further.