From dc841a62942c3930c2c124d22974e8795ea724c1 Mon Sep 17 00:00:00 2001 From: thatcher Date: Thu, 29 Dec 2011 17:14:42 -0500 Subject: [PATCH] commented out unreported profiling code. removed psuedo private properties and accessors of Profiler preferring direct property access. will eventuall reconnect profiler via AOP and include 'profile' option in Viewer which is false by default --- openseadragon.js | 244 ++++++++++++++++++++++----------------------- src/drawer.js | 4 +- src/imageloader.js | 1 - src/overlay.js | 72 +++++++------ src/point.js | 49 +++++---- src/profiler.js | 115 ++++++++------------- src/viewer.js | 4 +- 7 files changed, 238 insertions(+), 251 deletions(-) delete mode 100644 src/imageloader.js diff --git a/openseadragon.js b/openseadragon.js index e3bec59f..3c5f080c 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -2029,7 +2029,7 @@ function updateOnce( viewer ) { return; } - viewer.profiler.beginUpdate(); + //viewer.profiler.beginUpdate(); var containerSize = $.Utils.getElementSize( viewer.container ); @@ -2064,7 +2064,7 @@ function updateOnce( viewer ) { viewer._animating = animated; - viewer.profiler.endUpdate(); + //viewer.profiler.endUpdate(); }; /////////////////////////////////////////////////////////////////////////////// @@ -2226,38 +2226,53 @@ $.Point = function(x, y) { $.Point.prototype = { - plus: function(point) { - return new $.Point(this.x + point.x, this.y + point.y); + plus: function( point ) { + return new $.Point( + this.x + point.x, + this.y + point.y + ); }, - minus: function(point) { - return new $.Point(this.x - point.x, this.y - point.y); + minus: function( point ) { + return new $.Point( + this.x - point.x, + this.y - point.y + ); }, - times: function(factor) { - return new $.Point(this.x * factor, this.y * factor); + times: function( factor ) { + return new $.Point( + this.x * factor, + this.y * factor + ); }, - divide: function(factor) { - return new $.Point(this.x / factor, this.y / factor); + divide: function( factor ) { + return new $.Point( + this.x / factor, + this.y / factor + ); }, negate: function() { - return new $.Point(-this.x, -this.y); + return new $.Point( -this.x, -this.y ); }, - distanceTo: function(point) { - return Math.sqrt(Math.pow(this.x - point.x, 2) + - Math.pow(this.y - point.y, 2)); + distanceTo: function( point ) { + return Math.sqrt( + Math.pow( this.x - point.x, 2 ) + + Math.pow( this.y - point.y, 2 ) + ); }, - apply: function(func) { - return new $.Point(func(this.x), func(this.y)); + apply: function( func ) { + return new $.Point( func(this.x), func(this.y) ); }, - equals: function(point) { - return (point instanceof $.Point) && - (this.x === point.x) && (this.y === point.y); + equals: function( point ) { + return ( point instanceof $.Point ) && + ( this.x === point.x ) && + ( this.y === point.y ); }, toString: function() { @@ -2271,117 +2286,82 @@ $.Point.prototype = { $.Profiler = function() { - this._midUpdate = false; - this._numUpdates = 0; + this.midUpdate = false; + this.numUpdates = 0; - this._lastBeginTime = null; - this._lastEndTime = null; + this.lastBeginTime = null; + this.lastEndTime = null; - this._minUpdateTime = Infinity; - this._avgUpdateTime = 0; - this._maxUpdateTime = 0; + this.minUpdateTime = Infinity; + this.avgUpdateTime = 0; + this.maxUpdateTime = 0; - this._minIdleTime = Infinity; - this._avgIdleTime = 0; - this._maxIdleTime = 0; + this.minIdleTime = Infinity; + this.avgIdleTime = 0; + this.maxIdleTime = 0; }; $.Profiler.prototype = { - getAvgUpdateTime: function() { - return this._avgUpdateTime; - }, - - getMinUpdateTime: function() { - return this._minUpdateTime; - }, - - getMaxUpdateTime: function() { - return this._maxUpdateTime; - }, - - - getAvgIdleTime: function() { - return this._avgIdleTime; - }, - - getMinIdleTime: function() { - return this._minIdleTime; - }, - - getMaxIdleTime: function() { - return this._maxIdleTime; - }, - - - isMidUpdate: function() { - return this._midUpdate; - }, - - getNumUpdates: function() { - return this._numUpdates; - }, - - beginUpdate: function() { - if (this._midUpdate) { + if (this.midUpdate) { this.endUpdate(); } - this._midUpdate = true; - this._lastBeginTime = new Date().getTime(); + this.midUpdate = true; + this.lastBeginTime = new Date().getTime(); - if (this._numUpdates < 1) { + if (this.numUpdates < 1) { return; // this is the first update } - var time = this._lastBeginTime - this._lastEndTime; + var time = this.lastBeginTime - this.lastEndTime; - this._avgIdleTime = (this._avgIdleTime * (this._numUpdates - 1) + time) / this._numUpdates; + this.avgIdleTime = (this.avgIdleTime * (this.numUpdates - 1) + time) / this.numUpdates; - if (time < this._minIdleTime) { - this._minIdleTime = time; + if (time < this.minIdleTime) { + this.minIdleTime = time; } - if (time > this._maxIdleTime) { - this._maxIdleTime = time; + if (time > this.maxIdleTime) { + this.maxIdleTime = time; } }, endUpdate: function() { - if (!this._midUpdate) { + if (!this.midUpdate) { return; } - this._lastEndTime = new Date().getTime(); - this._midUpdate = false; + this.lastEndTime = new Date().getTime(); + this.midUpdate = false; - var time = this._lastEndTime - this._lastBeginTime; + var time = this.lastEndTime - this.lastBeginTime; - this._numUpdates++; - this._avgUpdateTime = (this._avgUpdateTime * (this._numUpdates - 1) + time) / this._numUpdates; + this.numUpdates++; + this.avgUpdateTime = (this.avgUpdateTime * (this.numUpdates - 1) + time) / this.numUpdates; - if (time < this._minUpdateTime) { - this._minUpdateTime = time; + if (time < this.minUpdateTime) { + this.minUpdateTime = time; } - if (time > this._maxUpdateTime) { - this._maxUpdateTime = time; + if (time > this.maxUpdateTime) { + this.maxUpdateTime = time; } }, clearProfile: function() { - this._midUpdate = false; - this._numUpdates = 0; + this.midUpdate = false; + this.numUpdates = 0; - this._lastBeginTime = null; - this._lastEndTime = null; + this.lastBeginTime = null; + this.lastEndTime = null; - this._minUpdateTime = Infinity; - this._avgUpdateTime = 0; - this._maxUpdateTime = 0; + this.minUpdateTime = Infinity; + this.avgUpdateTime = 0; + this.maxUpdateTime = 0; - this._minIdleTime = Infinity; - this._avgIdleTime = 0; - this._maxIdleTime = 0; + this.minIdleTime = Infinity; + this.avgIdleTime = 0; + this.maxIdleTime = 0; } }; @@ -3194,7 +3174,6 @@ $.Tile.prototype = { }( OpenSeadragon )); (function( $ ){ - $.OverlayPlacement = { CENTER: 0, @@ -3208,15 +3187,26 @@ $.Tile.prototype = { LEFT: 8 }; - $.Overlay = function(elmt, loc, placement) { + $.Overlay = function(elmt, location, placement) { this.elmt = elmt; - this.scales = (loc instanceof $.Rect); - this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); - this.position = new $.Point(loc.x, loc.y); - this.size = new $.Point(loc.width, loc.height); + this.scales = location instanceof $.Rect; + this.bounds = new $.Rect( + location.x, + location.y, + location.width, + location.height) + ; + this.position = new $.Point( + location.x, + location.y + ); + this.size = new $.Point( + location.width, + location.height + ); this.style = elmt.style; // rects are always top-left - this.placement = loc instanceof $.Point ? + this.placement = location instanceof $.Point ? placement : $.OverlayPlacement.TOP_LEFT; }; @@ -3275,41 +3265,45 @@ $.Tile.prototype = { style.height = ""; } }, - drawHTML: function(container) { - var elmt = this.elmt; - var style = this.style; - var scales = this.scales; + drawHTML: function( container ) { + var elmt = this.elmt, + style = this.style, + scales = this.scales, + position, + size; - if (elmt.parentNode != container) { - container.appendChild(elmt); + if ( elmt.parentNode != container ) { + container.appendChild( elmt ); } - if (!scales) { - this.size = $.Utils.getElementSize(elmt); + if ( !scales ) { + this.size = $.Utils.getElementSize( elmt ); } - var position = this.position; - var size = this.size; + position = this.position; + size = this.size; - this.adjust(position, size); + this.adjust( position, size ); - position = position.apply(Math.floor); - size = size.apply(Math.ceil); + position = position.apply( Math.floor ); + size = size.apply( Math.ceil ); - style.left = position.x + "px"; - style.top = position.y + "px"; + style.left = position.x + "px"; + style.top = position.y + "px"; style.position = "absolute"; - if (scales) { - style.width = size.x + "px"; + if ( scales ) { + style.width = size.x + "px"; style.height = size.y + "px"; } }, - update: function(loc, placement) { - this.scales = (loc instanceof $.Rect); - this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); - this.placement = loc instanceof $.Point ? - placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left + update: function( loc, placement ) { + this.scales = ( loc instanceof $.Rect ); + this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); + // rects are always top-left + this.placement = loc instanceof $.Point ? + placement : + $.OverlayPlacement.TOP_LEFT; } }; @@ -3893,11 +3887,11 @@ $.Drawer.prototype = { }, update: function() { - this._profiler.beginUpdate(); + //this._profiler.beginUpdate(); this._midUpdate = true; this._updateActual(); this._midUpdate = false; - this._profiler.endUpdate(); + //this._profiler.endUpdate(); }, loadImage: function(src, callback) { diff --git a/src/drawer.js b/src/drawer.js index 42a997a1..09729563 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -576,11 +576,11 @@ $.Drawer.prototype = { }, update: function() { - this._profiler.beginUpdate(); + //this._profiler.beginUpdate(); this._midUpdate = true; this._updateActual(); this._midUpdate = false; - this._profiler.endUpdate(); + //this._profiler.endUpdate(); }, loadImage: function(src, callback) { diff --git a/src/imageloader.js b/src/imageloader.js deleted file mode 100644 index 8b137891..00000000 --- a/src/imageloader.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/overlay.js b/src/overlay.js index a0c0c1ee..e033e771 100644 --- a/src/overlay.js +++ b/src/overlay.js @@ -1,6 +1,5 @@ (function( $ ){ - $.OverlayPlacement = { CENTER: 0, @@ -14,15 +13,26 @@ LEFT: 8 }; - $.Overlay = function(elmt, loc, placement) { + $.Overlay = function(elmt, location, placement) { this.elmt = elmt; - this.scales = (loc instanceof $.Rect); - this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); - this.position = new $.Point(loc.x, loc.y); - this.size = new $.Point(loc.width, loc.height); + this.scales = location instanceof $.Rect; + this.bounds = new $.Rect( + location.x, + location.y, + location.width, + location.height) + ; + this.position = new $.Point( + location.x, + location.y + ); + this.size = new $.Point( + location.width, + location.height + ); this.style = elmt.style; // rects are always top-left - this.placement = loc instanceof $.Point ? + this.placement = location instanceof $.Point ? placement : $.OverlayPlacement.TOP_LEFT; }; @@ -81,41 +91,45 @@ style.height = ""; } }, - drawHTML: function(container) { - var elmt = this.elmt; - var style = this.style; - var scales = this.scales; + drawHTML: function( container ) { + var elmt = this.elmt, + style = this.style, + scales = this.scales, + position, + size; - if (elmt.parentNode != container) { - container.appendChild(elmt); + if ( elmt.parentNode != container ) { + container.appendChild( elmt ); } - if (!scales) { - this.size = $.Utils.getElementSize(elmt); + if ( !scales ) { + this.size = $.Utils.getElementSize( elmt ); } - var position = this.position; - var size = this.size; + position = this.position; + size = this.size; - this.adjust(position, size); + this.adjust( position, size ); - position = position.apply(Math.floor); - size = size.apply(Math.ceil); + position = position.apply( Math.floor ); + size = size.apply( Math.ceil ); - style.left = position.x + "px"; - style.top = position.y + "px"; + style.left = position.x + "px"; + style.top = position.y + "px"; style.position = "absolute"; - if (scales) { - style.width = size.x + "px"; + if ( scales ) { + style.width = size.x + "px"; style.height = size.y + "px"; } }, - update: function(loc, placement) { - this.scales = (loc instanceof $.Rect); - this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); - this.placement = loc instanceof $.Point ? - placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left + update: function( loc, placement ) { + this.scales = ( loc instanceof $.Rect ); + this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); + // rects are always top-left + this.placement = loc instanceof $.Point ? + placement : + $.OverlayPlacement.TOP_LEFT; } }; diff --git a/src/point.js b/src/point.js index 569288c8..d5cd2bcb 100644 --- a/src/point.js +++ b/src/point.js @@ -8,38 +8,53 @@ $.Point = function(x, y) { $.Point.prototype = { - plus: function(point) { - return new $.Point(this.x + point.x, this.y + point.y); + plus: function( point ) { + return new $.Point( + this.x + point.x, + this.y + point.y + ); }, - minus: function(point) { - return new $.Point(this.x - point.x, this.y - point.y); + minus: function( point ) { + return new $.Point( + this.x - point.x, + this.y - point.y + ); }, - times: function(factor) { - return new $.Point(this.x * factor, this.y * factor); + times: function( factor ) { + return new $.Point( + this.x * factor, + this.y * factor + ); }, - divide: function(factor) { - return new $.Point(this.x / factor, this.y / factor); + divide: function( factor ) { + return new $.Point( + this.x / factor, + this.y / factor + ); }, negate: function() { - return new $.Point(-this.x, -this.y); + return new $.Point( -this.x, -this.y ); }, - distanceTo: function(point) { - return Math.sqrt(Math.pow(this.x - point.x, 2) + - Math.pow(this.y - point.y, 2)); + distanceTo: function( point ) { + return Math.sqrt( + Math.pow( this.x - point.x, 2 ) + + Math.pow( this.y - point.y, 2 ) + ); }, - apply: function(func) { - return new $.Point(func(this.x), func(this.y)); + apply: function( func ) { + return new $.Point( func(this.x), func(this.y) ); }, - equals: function(point) { - return (point instanceof $.Point) && - (this.x === point.x) && (this.y === point.y); + equals: function( point ) { + return ( point instanceof $.Point ) && + ( this.x === point.x ) && + ( this.y === point.y ); }, toString: function() { diff --git a/src/profiler.js b/src/profiler.js index 7df6eb33..17703ec8 100644 --- a/src/profiler.js +++ b/src/profiler.js @@ -3,117 +3,82 @@ $.Profiler = function() { - this._midUpdate = false; - this._numUpdates = 0; + this.midUpdate = false; + this.numUpdates = 0; - this._lastBeginTime = null; - this._lastEndTime = null; + this.lastBeginTime = null; + this.lastEndTime = null; - this._minUpdateTime = Infinity; - this._avgUpdateTime = 0; - this._maxUpdateTime = 0; + this.minUpdateTime = Infinity; + this.avgUpdateTime = 0; + this.maxUpdateTime = 0; - this._minIdleTime = Infinity; - this._avgIdleTime = 0; - this._maxIdleTime = 0; + this.minIdleTime = Infinity; + this.avgIdleTime = 0; + this.maxIdleTime = 0; }; $.Profiler.prototype = { - getAvgUpdateTime: function() { - return this._avgUpdateTime; - }, - - getMinUpdateTime: function() { - return this._minUpdateTime; - }, - - getMaxUpdateTime: function() { - return this._maxUpdateTime; - }, - - - getAvgIdleTime: function() { - return this._avgIdleTime; - }, - - getMinIdleTime: function() { - return this._minIdleTime; - }, - - getMaxIdleTime: function() { - return this._maxIdleTime; - }, - - - isMidUpdate: function() { - return this._midUpdate; - }, - - getNumUpdates: function() { - return this._numUpdates; - }, - - beginUpdate: function() { - if (this._midUpdate) { + if (this.midUpdate) { this.endUpdate(); } - this._midUpdate = true; - this._lastBeginTime = new Date().getTime(); + this.midUpdate = true; + this.lastBeginTime = new Date().getTime(); - if (this._numUpdates < 1) { + if (this.numUpdates < 1) { return; // this is the first update } - var time = this._lastBeginTime - this._lastEndTime; + var time = this.lastBeginTime - this.lastEndTime; - this._avgIdleTime = (this._avgIdleTime * (this._numUpdates - 1) + time) / this._numUpdates; + this.avgIdleTime = (this.avgIdleTime * (this.numUpdates - 1) + time) / this.numUpdates; - if (time < this._minIdleTime) { - this._minIdleTime = time; + if (time < this.minIdleTime) { + this.minIdleTime = time; } - if (time > this._maxIdleTime) { - this._maxIdleTime = time; + if (time > this.maxIdleTime) { + this.maxIdleTime = time; } }, endUpdate: function() { - if (!this._midUpdate) { + if (!this.midUpdate) { return; } - this._lastEndTime = new Date().getTime(); - this._midUpdate = false; + this.lastEndTime = new Date().getTime(); + this.midUpdate = false; - var time = this._lastEndTime - this._lastBeginTime; + var time = this.lastEndTime - this.lastBeginTime; - this._numUpdates++; - this._avgUpdateTime = (this._avgUpdateTime * (this._numUpdates - 1) + time) / this._numUpdates; + this.numUpdates++; + this.avgUpdateTime = (this.avgUpdateTime * (this.numUpdates - 1) + time) / this.numUpdates; - if (time < this._minUpdateTime) { - this._minUpdateTime = time; + if (time < this.minUpdateTime) { + this.minUpdateTime = time; } - if (time > this._maxUpdateTime) { - this._maxUpdateTime = time; + if (time > this.maxUpdateTime) { + this.maxUpdateTime = time; } }, clearProfile: function() { - this._midUpdate = false; - this._numUpdates = 0; + this.midUpdate = false; + this.numUpdates = 0; - this._lastBeginTime = null; - this._lastEndTime = null; + this.lastBeginTime = null; + this.lastEndTime = null; - this._minUpdateTime = Infinity; - this._avgUpdateTime = 0; - this._maxUpdateTime = 0; + this.minUpdateTime = Infinity; + this.avgUpdateTime = 0; + this.maxUpdateTime = 0; - this._minIdleTime = Infinity; - this._avgIdleTime = 0; - this._maxIdleTime = 0; + this.minIdleTime = Infinity; + this.avgIdleTime = 0; + this.maxIdleTime = 0; } }; diff --git a/src/viewer.js b/src/viewer.js index 1ced5b05..c1ea18e6 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -755,7 +755,7 @@ function updateOnce( viewer ) { return; } - viewer.profiler.beginUpdate(); + //viewer.profiler.beginUpdate(); var containerSize = $.Utils.getElementSize( viewer.container ); @@ -790,7 +790,7 @@ function updateOnce( viewer ) { viewer._animating = animated; - viewer.profiler.endUpdate(); + //viewer.profiler.endUpdate(); }; ///////////////////////////////////////////////////////////////////////////////