Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2989)

Unified Diff: chrome/browser/resources/sync_internals/sync_node_browser.js

Issue 7049028: [Sync] Speed up Javascript node operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/sync_internals/chrome_sync.js ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/sync_internals/sync_node_browser.js
diff --git a/chrome/browser/resources/sync_internals/sync_node_browser.js b/chrome/browser/resources/sync_internals/sync_node_browser.js
index 493933755919d28fcd2155d03e92d3c7413440f8..3ce44697e01b8178c190c762c0ea0bce149b5a10 100644
--- a/chrome/browser/resources/sync_internals/sync_node_browser.js
+++ b/chrome/browser/resources/sync_internals/sync_node_browser.js
@@ -18,6 +18,23 @@ cr.define('chrome.sync', function() {
// hide all these details.
/**
+ * Returns an object which measures elapsed time.
+ */
+ var makeTimer = function() {
+ var start = new Date();
+
+ return {
+ /**
+ * @return {number} The number of seconds since the timer was
+ * created.
+ */
+ get elapsedSeconds() {
+ return ((new Date()).getTime() - start.getTime()) / 1000.0;
+ }
+ };
+ };
+
+ /**
* Gets all children of the given node and passes it to the given
* callback.
* @param {Object} nodeInfo The info for the node whose children we
@@ -26,16 +43,19 @@ cr.define('chrome.sync', function() {
* children.
*/
function getSyncNodeChildren(nodeInfo, callback) {
- var children = [];
- function processChildInfo(childNodeInfo) {
- if (!childNodeInfo) {
+ var timer = makeTimer();
+ chrome.sync.getChildNodeIds(nodeInfo.id, function(childNodeIds) {
+ console.debug('getChildNodeIds took ' +
+ timer.elapsedSeconds + 's to retrieve ' +
+ childNodeIds.length + ' ids');
+ timer = makeTimer();
+ chrome.sync.getNodesById(childNodeIds, function(children) {
+ console.debug('getNodesById took ' +
+ timer.elapsedSeconds + 's to retrieve ' +
+ children.length + ' nodes');
callback(children);
- return;
- }
- children.push(childNodeInfo);
- chrome.sync.getNodeById(childNodeInfo.successorId, processChildInfo);
- };
- chrome.sync.getNodeById(nodeInfo.firstChildId, processChildInfo);
+ });
+ });
}
/**
@@ -59,10 +79,13 @@ cr.define('chrome.sync', function() {
treeItem.addEventListener('expand', function(event) {
if (!treeItem.triggeredLoad_) {
getSyncNodeChildren(nodeInfo, function(children) {
+ var timer = makeTimer();
for (var i = 0; i < children.length; ++i) {
var childTreeItem = makeNodeTreeItem(children[i]);
treeItem.add(childTreeItem);
}
+ console.debug('adding ' + children.length + ' children took ' +
+ timer.elapsedSeconds + 's');
});
treeItem.triggeredLoad_ = true;
}
« no previous file with comments | « chrome/browser/resources/sync_internals/chrome_sync.js ('k') | chrome/browser/sync/engine/syncapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698