-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(core): Optimize data.kindOf data.isOfKind (#124)
- Loading branch information
Showing
5 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import { Suite } from 'benchmark' | ||
import I from 'immutable' | ||
|
||
import { canonical, isOfKind, kindOf } from '../' | ||
|
||
describe('element benchmarks', () => { | ||
const detective1 = I.fromJS({ | ||
kind: 'detective', | ||
name: 'Sherlock Holmes', | ||
}) | ||
const detective2 = I.fromJS({ | ||
kind: ['detective', 'the'], | ||
name: 'Sherlock Holmes', | ||
}) | ||
const detective3 = I.fromJS({ | ||
kind: ['detective', 'the', 'smartest'], | ||
name: 'Sherlock Holmes', | ||
}) | ||
const detective4 = I.fromJS({ | ||
kind: ['detective', 'the', 'smartest', 'ever'], | ||
name: 'Sherlock Holmes', | ||
}) | ||
|
||
test.skip('canonical', () => { | ||
new Suite() | ||
.add('canonical memoized', () => { | ||
canonical('detective') | ||
canonical(['detective', 'the']) | ||
canonical(['detective', 'the', 'smartest']) | ||
canonical(['detective', 'the', 'smartest', 'ever']) | ||
}) | ||
.on('cycle', function(event) { | ||
console.log(event.target.toString()) | ||
}) | ||
.run() | ||
}) | ||
|
||
test.skip('isOfKind', () => { | ||
new Suite() | ||
.add('isOfKind memoized', () => { | ||
isOfKind('detective', detective3) | ||
isOfKind(['detective', 'the'], detective3) | ||
isOfKind(['detective', 'the', 'smartest'], detective3) | ||
isOfKind(['detective', 'the', 'smartest', 'ever'], detective3) | ||
}) | ||
.on('cycle', function(event) { | ||
console.log(event.target.toString()) | ||
}) | ||
.run() | ||
}) | ||
|
||
test.skip('kindOf', () => { | ||
new Suite() | ||
.add('kindOf memoized', () => { | ||
kindOf(detective1) | ||
kindOf(detective2) | ||
kindOf(detective3) | ||
kindOf(detective4) | ||
}) | ||
.on('cycle', function(event) { | ||
console.log(event.target.toString()) | ||
}) | ||
.run() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters