-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor component tree updates Rather than lumping this in with the profile updates, which are for the render performance tab, I started trying to split things out a bit. Hopefully this is step one of many of making this easier to follow! * Move some render functions to utils * Fix tests
- Loading branch information
1 parent
e8f2502
commit f4bca8e
Showing
3 changed files
with
120 additions
and
84 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
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,58 @@ | ||
import ProfileManager from 'ember-debug/models/profile-manager'; | ||
|
||
const Ember = window.Ember; | ||
const { run: { later } } = Ember; | ||
|
||
let profileManager, queue; | ||
|
||
export function setupQueue() { | ||
profileManager = new ProfileManager(); | ||
queue = []; | ||
|
||
return { profileManager, queue }; | ||
} | ||
|
||
/** | ||
* Recursively flatten all profiles and their children | ||
* @param {Profile[]} profiles An array of profiles | ||
* @param {Array} array The array to hold the flattened profiles | ||
* @return {*|Array} | ||
*/ | ||
export function flatten(profiles, array = []) { | ||
profiles.forEach(profile => { | ||
array.push(profile); | ||
flatten(profile.children, array); | ||
}); | ||
return array; | ||
} | ||
|
||
/** | ||
* Push a new profile into the queue | ||
* @param info | ||
* @return {number} | ||
*/ | ||
export function addToQueue(info) { | ||
const index = queue.push(info); | ||
if (index === 1) { | ||
later(_flush, 50); | ||
} | ||
return index - 1; | ||
} | ||
|
||
function _flush() { | ||
let entry, i; | ||
for (i = 0; i < queue.length; i++) { | ||
entry = queue[i]; | ||
if (entry.type === 'began') { | ||
// If there was an error during rendering `entry.endedIndex` never gets set. | ||
if (entry.endedIndex) { | ||
queue[entry.endedIndex].profileNode = profileManager.began(entry.timestamp, entry.payload, entry.now); | ||
} | ||
} else { | ||
profileManager.ended(entry.timestamp, entry.payload, entry.profileNode); | ||
} | ||
|
||
} | ||
queue.length = 0; | ||
} | ||
|
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