Skip to content

Commit

Permalink
Add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 28, 2019
1 parent 6dfa1a9 commit e141783
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,40 @@ Fast cartesian product.

Work in progress!

# Benchmarks

Those [benchmarks](benchmarks/main.js) compares the performance of this library
against alternatives
([`cartesian-product`](https://github.com/izaakschroeder/cartesian-product),
[`cartesian`](https://github.com/alexindigo/cartesian) and
[`lodash.product`](https://github.com/SeregPie/lodash.product)).

```
fast-cartesian (1 array) 278869 ops/sec
fast-cartesian (2 arrays) 304239 ops/sec
fast-cartesian (4 arrays) 213092 ops/sec
fast-cartesian (8 arrays) 379142 ops/sec
fast-cartesian (16 arrays) 159605 ops/sec
cartesian-product (1 array) 245936 ops/sec
cartesian-product (2 arrays) 232967 ops/sec
cartesian-product (4 arrays) 72620 ops/sec
cartesian-product (8 arrays) 55621 ops/sec
cartesian-product (16 arrays) 37949 ops/sec
cartesian (1 array) 127550 ops/sec
cartesian (2 arrays) 51323 ops/sec
cartesian (4 arrays) 43785 ops/sec
cartesian (8 arrays) 33748 ops/sec
cartesian (16 arrays) 22163 ops/sec
lodash.product (1 array) 19958 ops/sec
lodash.product (2 arrays) 18865 ops/sec
lodash.product (4 arrays) 17608 ops/sec
lodash.product (8 arrays) 14205 ops/sec
lodash.product (16 arrays) 9667 ops/sec
```

# Support

If you found a bug or would like a new feature, _don't hesitate_ to
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const getVariant = function(index, length) {
const unitLength = 2 ** (2 ** (length - index - 1))
const unit = Array.from({ length: unitLength }, getIndex)
const args = Array.from({ length: dimensions }, () => unit)
const title = `${dimensions} dimensions`
const title =
dimensions === 1 ? `${dimensions} array` : `${dimensions} arrays`
return [title, args]
}

Expand Down

0 comments on commit e141783

Please sign in to comment.