From 60f3b28c5432184a6732633a282d364ea6255e54 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Fri, 27 May 2011 00:35:43 +0900 Subject: [PATCH] add module for performance tuning --- modules/browser.js | 6 ++++++ modules/rap.js | 11 +++++++++++ modules/utils.js | 7 +++++++ modules/window.js | 7 +++++++ 4 files changed, 31 insertions(+) create mode 100644 modules/rap.js diff --git a/modules/browser.js b/modules/browser.js index 95d0c31d..c15fc52b 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -38,6 +38,9 @@ const EXPORTED_SYMBOLS = ['TreeStyleTabBrowser']; const Cc = Components.classes; const Ci = Components.interfaces; +// Components.utils.import('resource://treestyletab-modules/rap.js'); +// rap(); + Components.utils.import('resource://treestyletab-modules/window.js'); function TreeStyleTabBrowser(aWindowService, aTabBrowser) @@ -526,6 +529,7 @@ TreeStyleTabBrowser.prototype = { init : function TSTBrowser_init() { +// rap('browser/init start'); this.stopRendering(); var w = this.window; @@ -605,6 +609,7 @@ TreeStyleTabBrowser.prototype = { this.fireTabbarPositionEvent(false, 'top', position); /* PUBLIC API */ this.startRendering(); +// rap('browser/init end'); }, _initTabbrowserExtraContents : function TSTBrowser_initTabbrowserExtraContents() @@ -5248,4 +5253,5 @@ TreeStyleTabBrowser.prototype = { cancelHideTabbarForFeedback : function TSTBrowser_cancelHideTabbarForFeedback() { this.autoHide.cancelHideForFeedback(); } }; +// rap('end of definition of browser'); diff --git a/modules/rap.js b/modules/rap.js new file mode 100644 index 00000000..bd3e5ca4 --- /dev/null +++ b/modules/rap.js @@ -0,0 +1,11 @@ +const EXPORTED_SYMBOLS = ['rap']; + +var last = -1; +var start = Date.now(); + +function rap(aMessage) { + var now = Date.now(); + var time = last < 0 ? 0 : (now - last); + dump(time+' (total '+(now - start)+') : '+(aMessage || Components.stack.caller)+'\n'); + last = now; +} diff --git a/modules/utils.js b/modules/utils.js index d6f2b056..b3c1ef0f 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -40,6 +40,8 @@ const Ci = Components.interfaces; Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); +// Components.utils.import('resource://treestyletab-modules/rap.js'); +// rap(); Components.utils.import('resource://treestyletab-modules/lib/prefs.js'); Components.utils.import('resource://treestyletab-modules/lib/namespace.jsm'); var window = getNamespaceFor('piro.sakura.ne.jp'); @@ -79,6 +81,7 @@ XPCOMUtils.defineLazyGetter(this, 'confirmWithTab', function() { Components.utils.import('resource://treestyletab-modules/lib/confirmWithTab.js', ns); return ns.confirmWithTab; }); +// rap('end of definition of lazy getters'); var TreeStyleTabUtils = { __proto__ : window['piro.sakura.ne.jp'].prefs, @@ -332,6 +335,7 @@ var TreeStyleTabUtils = { init : function TSTUtils_init() { +// rap('utils/init start'); if (this._initialized) return; this.isMac = this.XULAppInfo.OS == 'Darwin'; @@ -361,6 +365,7 @@ var TreeStyleTabUtils = { catch(e) { dump(e+'\n'); } +// rap('utils/init end'); }, _initialized : false, applyPlatformDefaultPrefs : function TSTUtils_applyPlatformDefaultPrefs() @@ -2429,5 +2434,7 @@ var TreeStyleTabUtils = { }; +// rap('end of definition of utils'); TreeStyleTabUtils.init(); +// rap('end of initialization of utils'); diff --git a/modules/window.js b/modules/window.js index 5d148a0f..0ac23cbf 100644 --- a/modules/window.js +++ b/modules/window.js @@ -40,6 +40,8 @@ const Ci = Components.interfaces; Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); +// Components.utils.import('resource://treestyletab-modules/rap.js'); +// rap(); Components.utils.import('resource://treestyletab-modules/utils.js'); XPCOMUtils.defineLazyGetter(this, 'TreeStyleTabBrowser', function() { var ns = {}; @@ -282,6 +284,7 @@ TreeStyleTabWindow.prototype = { preInit : function TSTWindow_preInit() { +// rap('window/preInit start'); if (this.preInitialized) return; this.preInitialized = true; @@ -298,6 +301,7 @@ TreeStyleTabWindow.prototype = { // initialize theme this.onPrefChange('extensions.treestyletab.tabbar.style'); +// rap('window/preInit end'); }, preInitialized : false, @@ -407,6 +411,7 @@ TreeStyleTabWindow.prototype = { init : function TSTWindow_init() { +// rap('window/init start'); var w = this.window; w.removeEventListener('load', this, false); w.addEventListener('unload', this, false); @@ -455,6 +460,7 @@ TreeStyleTabWindow.prototype = { if (this.isAutoHide) this.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode'); this.onPrefChange('extensions.treestyletab.autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'); +// rap('window/init end'); }, initialized : false, @@ -1606,4 +1612,5 @@ TreeStyleTabWindow.prototype = { } }; +// rap('end of definition of window');