R.uniq is slower than Ramda for big arrays
bovine3dom opened this issue · 5 comments
Minimal example:
// Make an array of 10,000 strings with some repetition
let strings = R.map(() => Math.floor(Math.random() * 1000) + "", R.range(0,10000))
// Time R.uniq
const t0 = new Date().getTime()
R.uniq(strings)
const t1 = new Date().getTime()
// Store the result
const result = t1-t0
console.log(t1 - t0)
- in Ramda: ~1ms
- in Rambda: ~600ms
Related downstream issue: tridactyl/tridactyl#3772
: )
I will run the code through Rambda benchmark and I'll get back to you.
Thank you @bovine3dom as this is a serious issue, which I can confirm. I will report again when there is a progress on this problem.
I have pinned the reason for this issue. Expect a fix with version 6.9.0
.
6.9.0
was released with improved performance for R.uniq
and several other related methods. I am closing the issue, but please feel free to comment further.
As a side note I am adding a bit more information about the result.
During developing the fix, I realized that underlying issue was lack of correct benchmarking process. As a result, there is now a new format for Rambda benchmark(https://github.com/selfrefactor/rambda/blob/master/source/benchmarks/uniq.js) which can produce dev-only benchmark result: https://github.com/selfrefactor/rambda-scripts/blob/master/scripts/run-benchmarks/benchmark-results/uniq.json
UNIQ-ALL
key refers to the result used in README, while UNIQ-0
, UNIQ-1
, etc. refers to the index of modes
list used to generate the benchmark.