-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
less dom reads #358
Merged
Merged
less dom reads #358
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a638c0a
initial
alexreardon f9779a4
fixing tests
alexreardon a03639b
more tests
alexreardon 4495112
fixing auto scroller tests
alexreardon 60b3c10
progressing on tests
alexreardon 87d09cd
cleaning up tests for fluid-scroller
alexreardon 48e3a5c
fixing jump scroller
alexreardon 00a5d9d
move-to-next-index
alexreardon fcf9559
get-closest-draggable. unconnected draggable
alexreardon bc39d9a
fixing more tests
alexreardon a0ad342
perf improvements for stories. new debug middleware
alexreardon cc39f4e
Merge branch 'master' into less-dom-reads
alexreardon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another debug middleware - this one averages the time taken for actions and prints a result |
||
/* eslint-disable no-console */ | ||
import type { Action } from '../../types'; | ||
|
||
type Bucket = { | ||
[key: string]: number[], | ||
} | ||
|
||
const average = (values: number[]): number => { | ||
const sum: number = values.reduce((previous: number, current: number) => previous + current, 0); | ||
return sum / values.length; | ||
}; | ||
|
||
export default (groupSize: number) => { | ||
console.log('Starting average action timer middleware'); | ||
console.log(`Will take an average every ${groupSize} actions`); | ||
const bucket: Bucket = {}; | ||
|
||
return () => (next: (Action) => mixed) => (action: Action): mixed => { | ||
const start: number = performance.now(); | ||
|
||
const result: mixed = next(action); | ||
|
||
const end: number = performance.now(); | ||
|
||
const duration: number = end - start; | ||
|
||
if (!bucket[action.type]) { | ||
bucket[action.type] = [duration]; | ||
return result; | ||
} | ||
|
||
bucket[action.type].push(duration); | ||
|
||
if (bucket[action.type].length < groupSize) { | ||
return result; | ||
} | ||
|
||
console.warn(`Average time for ${action.type}`, average(bucket[action.type])); | ||
|
||
// reset | ||
bucket[action.type] = []; | ||
|
||
return result; | ||
}; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now computed in getViewport