Skip to content

Commit

Permalink
adding benchmarking back
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Apr 13, 2021
1 parent bd755b4 commit 946a0ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ By default, we apply our own _fast_ and _naive_ equality function to determine w
(By default) function arguments are considered equal if:

1. there is same amount of arguments
2. new arguments have strict equality (`===`) with the previous argument
2. each new argument has strict equality (`===`) with the previous argument
3. **[special case]** if the arguments are not `===` and they are both `NaN` then the argument is treated as equal

What these look like in practice:
What this looks like in practice:

```js
import { memoizeOne } from 'memoize-one';

// add all numbers provided to the function
const add = (...args = []) =>
args.reduce((current, value) => {
return current + value;
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/shallow-equal.js → benchmarks/shallow-equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const Benchmark = require('benchmark');

const suite = new Benchmark.Suite();

import areInputsEqual from '../src/are-inputs-equal';

function shallowEvery(a, b): boolean {
if (a.length !== b.length) {
return false;
Expand Down Expand Up @@ -47,6 +49,14 @@ suite.add('shallowFor with half-identical lists', () => {
shallowFor(listA, listB);
});

suite.add('our areInputsEqual with identical lists', () => {
areInputsEqual(listA, listA);
});

suite.add('our areInputsEqual with half-identical lists', () => {
areInputsEqual(listA, listB);
});

// eslint-disable-next-line no-console
suite.on('cycle', (e: any) => console.log(String(e.target)));

Expand Down

0 comments on commit 946a0ad

Please sign in to comment.