-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(grid): replace generators with iterable-returning functions
Turns out generators are slow, replacing them by plain iterables (arrays) improves performance by about 50%
- Loading branch information
1 parent
1aa8f73
commit 20655d1
Showing
7 changed files
with
96 additions
and
39 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,32 @@ | ||
declare const Benchmark: any | ||
|
||
export const createSuite = () => { | ||
const suite = new Benchmark.Suite() | ||
const runButton = document.createElement('button') | ||
|
||
suite.on('start', function () { | ||
console.clear() | ||
}) | ||
suite.on('cycle', function (event) { | ||
console.log(`${event.target}`) | ||
}) | ||
suite.on('complete', function () { | ||
console.log(`Fastest: ${this.filter('fastest').map('name')}`) | ||
}) | ||
|
||
runButton.type = 'button' | ||
runButton.innerHTML = 'Run benchmark' | ||
runButton.style.margin = '20px 0' | ||
runButton.addEventListener('click', () => { | ||
runButton.disabled = true | ||
runButton.innerHTML = 'Running benchmark…' | ||
suite.run({ async: true }) | ||
suite.on('complete', function () { | ||
runButton.disabled = false | ||
runButton.innerHTML = 'Run benchmark' | ||
}) | ||
}) | ||
document.body.prepend(runButton) | ||
|
||
return suite | ||
} |
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
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