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

This commit is contained in:
thatcher 2011-12-29 17:14:42 -05:00
parent 2b8fd1941d
commit dc841a6294
7 changed files with 238 additions and 251 deletions

View File

@ -2029,7 +2029,7 @@ function updateOnce( viewer ) {
return; return;
} }
viewer.profiler.beginUpdate(); //viewer.profiler.beginUpdate();
var containerSize = $.Utils.getElementSize( viewer.container ); var containerSize = $.Utils.getElementSize( viewer.container );
@ -2064,7 +2064,7 @@ function updateOnce( viewer ) {
viewer._animating = animated; viewer._animating = animated;
viewer.profiler.endUpdate(); //viewer.profiler.endUpdate();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -2227,19 +2227,31 @@ $.Point = function(x, y) {
$.Point.prototype = { $.Point.prototype = {
plus: function( point ) { plus: function( point ) {
return new $.Point(this.x + point.x, this.y + point.y); return new $.Point(
this.x + point.x,
this.y + point.y
);
}, },
minus: function( point ) { minus: function( point ) {
return new $.Point(this.x - point.x, this.y - point.y); return new $.Point(
this.x - point.x,
this.y - point.y
);
}, },
times: function( factor ) { times: function( factor ) {
return new $.Point(this.x * factor, this.y * factor); return new $.Point(
this.x * factor,
this.y * factor
);
}, },
divide: function( factor ) { divide: function( factor ) {
return new $.Point(this.x / factor, this.y / factor); return new $.Point(
this.x / factor,
this.y / factor
);
}, },
negate: function() { negate: function() {
@ -2247,8 +2259,10 @@ $.Point.prototype = {
}, },
distanceTo: function( point ) { distanceTo: function( point ) {
return Math.sqrt(Math.pow(this.x - point.x, 2) + return Math.sqrt(
Math.pow(this.y - point.y, 2)); Math.pow( this.x - point.x, 2 ) +
Math.pow( this.y - point.y, 2 )
);
}, },
apply: function( func ) { apply: function( func ) {
@ -2257,7 +2271,8 @@ $.Point.prototype = {
equals: function( point ) { equals: function( point ) {
return ( point instanceof $.Point ) && return ( point instanceof $.Point ) &&
(this.x === point.x) && (this.y === point.y); ( this.x === point.x ) &&
( this.y === point.y );
}, },
toString: function() { toString: function() {
@ -2271,117 +2286,82 @@ $.Point.prototype = {
$.Profiler = function() { $.Profiler = function() {
this._midUpdate = false; this.midUpdate = false;
this._numUpdates = 0; this.numUpdates = 0;
this._lastBeginTime = null; this.lastBeginTime = null;
this._lastEndTime = null; this.lastEndTime = null;
this._minUpdateTime = Infinity; this.minUpdateTime = Infinity;
this._avgUpdateTime = 0; this.avgUpdateTime = 0;
this._maxUpdateTime = 0; this.maxUpdateTime = 0;
this._minIdleTime = Infinity; this.minIdleTime = Infinity;
this._avgIdleTime = 0; this.avgIdleTime = 0;
this._maxIdleTime = 0; this.maxIdleTime = 0;
}; };
$.Profiler.prototype = { $.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() { beginUpdate: function() {
if (this._midUpdate) { if (this.midUpdate) {
this.endUpdate(); this.endUpdate();
} }
this._midUpdate = true; this.midUpdate = true;
this._lastBeginTime = new Date().getTime(); this.lastBeginTime = new Date().getTime();
if (this._numUpdates < 1) { if (this.numUpdates < 1) {
return; // this is the first update 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) { if (time < this.minIdleTime) {
this._minIdleTime = time; this.minIdleTime = time;
} }
if (time > this._maxIdleTime) { if (time > this.maxIdleTime) {
this._maxIdleTime = time; this.maxIdleTime = time;
} }
}, },
endUpdate: function() { endUpdate: function() {
if (!this._midUpdate) { if (!this.midUpdate) {
return; return;
} }
this._lastEndTime = new Date().getTime(); this.lastEndTime = new Date().getTime();
this._midUpdate = false; this.midUpdate = false;
var time = this._lastEndTime - this._lastBeginTime; var time = this.lastEndTime - this.lastBeginTime;
this._numUpdates++; this.numUpdates++;
this._avgUpdateTime = (this._avgUpdateTime * (this._numUpdates - 1) + time) / this._numUpdates; this.avgUpdateTime = (this.avgUpdateTime * (this.numUpdates - 1) + time) / this.numUpdates;
if (time < this._minUpdateTime) { if (time < this.minUpdateTime) {
this._minUpdateTime = time; this.minUpdateTime = time;
} }
if (time > this._maxUpdateTime) { if (time > this.maxUpdateTime) {
this._maxUpdateTime = time; this.maxUpdateTime = time;
} }
}, },
clearProfile: function() { clearProfile: function() {
this._midUpdate = false; this.midUpdate = false;
this._numUpdates = 0; this.numUpdates = 0;
this._lastBeginTime = null; this.lastBeginTime = null;
this._lastEndTime = null; this.lastEndTime = null;
this._minUpdateTime = Infinity; this.minUpdateTime = Infinity;
this._avgUpdateTime = 0; this.avgUpdateTime = 0;
this._maxUpdateTime = 0; this.maxUpdateTime = 0;
this._minIdleTime = Infinity; this.minIdleTime = Infinity;
this._avgIdleTime = 0; this.avgIdleTime = 0;
this._maxIdleTime = 0; this.maxIdleTime = 0;
} }
}; };
@ -3195,7 +3175,6 @@ $.Tile.prototype = {
(function( $ ){ (function( $ ){
$.OverlayPlacement = { $.OverlayPlacement = {
CENTER: 0, CENTER: 0,
TOP_LEFT: 1, TOP_LEFT: 1,
@ -3208,15 +3187,26 @@ $.Tile.prototype = {
LEFT: 8 LEFT: 8
}; };
$.Overlay = function(elmt, loc, placement) { $.Overlay = function(elmt, location, placement) {
this.elmt = elmt; this.elmt = elmt;
this.scales = (loc instanceof $.Rect); this.scales = location instanceof $.Rect;
this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); this.bounds = new $.Rect(
this.position = new $.Point(loc.x, loc.y); location.x,
this.size = new $.Point(loc.width, loc.height); 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; this.style = elmt.style;
// rects are always top-left // rects are always top-left
this.placement = loc instanceof $.Point ? this.placement = location instanceof $.Point ?
placement : placement :
$.OverlayPlacement.TOP_LEFT; $.OverlayPlacement.TOP_LEFT;
}; };
@ -3276,9 +3266,11 @@ $.Tile.prototype = {
} }
}, },
drawHTML: function( container ) { drawHTML: function( container ) {
var elmt = this.elmt; var elmt = this.elmt,
var style = this.style; style = this.style,
var scales = this.scales; scales = this.scales,
position,
size;
if ( elmt.parentNode != container ) { if ( elmt.parentNode != container ) {
container.appendChild( elmt ); container.appendChild( elmt );
@ -3288,8 +3280,8 @@ $.Tile.prototype = {
this.size = $.Utils.getElementSize( elmt ); this.size = $.Utils.getElementSize( elmt );
} }
var position = this.position; position = this.position;
var size = this.size; size = this.size;
this.adjust( position, size ); this.adjust( position, size );
@ -3308,8 +3300,10 @@ $.Tile.prototype = {
update: function( loc, placement ) { update: function( loc, placement ) {
this.scales = ( loc instanceof $.Rect ); this.scales = ( loc instanceof $.Rect );
this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height);
// rects are always top-left
this.placement = loc instanceof $.Point ? this.placement = loc instanceof $.Point ?
placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left placement :
$.OverlayPlacement.TOP_LEFT;
} }
}; };
@ -3893,11 +3887,11 @@ $.Drawer.prototype = {
}, },
update: function() { update: function() {
this._profiler.beginUpdate(); //this._profiler.beginUpdate();
this._midUpdate = true; this._midUpdate = true;
this._updateActual(); this._updateActual();
this._midUpdate = false; this._midUpdate = false;
this._profiler.endUpdate(); //this._profiler.endUpdate();
}, },
loadImage: function(src, callback) { loadImage: function(src, callback) {

View File

@ -576,11 +576,11 @@ $.Drawer.prototype = {
}, },
update: function() { update: function() {
this._profiler.beginUpdate(); //this._profiler.beginUpdate();
this._midUpdate = true; this._midUpdate = true;
this._updateActual(); this._updateActual();
this._midUpdate = false; this._midUpdate = false;
this._profiler.endUpdate(); //this._profiler.endUpdate();
}, },
loadImage: function(src, callback) { loadImage: function(src, callback) {

View File

@ -1 +0,0 @@

View File

@ -1,7 +1,6 @@
(function( $ ){ (function( $ ){
$.OverlayPlacement = { $.OverlayPlacement = {
CENTER: 0, CENTER: 0,
TOP_LEFT: 1, TOP_LEFT: 1,
@ -14,15 +13,26 @@
LEFT: 8 LEFT: 8
}; };
$.Overlay = function(elmt, loc, placement) { $.Overlay = function(elmt, location, placement) {
this.elmt = elmt; this.elmt = elmt;
this.scales = (loc instanceof $.Rect); this.scales = location instanceof $.Rect;
this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); this.bounds = new $.Rect(
this.position = new $.Point(loc.x, loc.y); location.x,
this.size = new $.Point(loc.width, loc.height); 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; this.style = elmt.style;
// rects are always top-left // rects are always top-left
this.placement = loc instanceof $.Point ? this.placement = location instanceof $.Point ?
placement : placement :
$.OverlayPlacement.TOP_LEFT; $.OverlayPlacement.TOP_LEFT;
}; };
@ -82,9 +92,11 @@
} }
}, },
drawHTML: function( container ) { drawHTML: function( container ) {
var elmt = this.elmt; var elmt = this.elmt,
var style = this.style; style = this.style,
var scales = this.scales; scales = this.scales,
position,
size;
if ( elmt.parentNode != container ) { if ( elmt.parentNode != container ) {
container.appendChild( elmt ); container.appendChild( elmt );
@ -94,8 +106,8 @@
this.size = $.Utils.getElementSize( elmt ); this.size = $.Utils.getElementSize( elmt );
} }
var position = this.position; position = this.position;
var size = this.size; size = this.size;
this.adjust( position, size ); this.adjust( position, size );
@ -114,8 +126,10 @@
update: function( loc, placement ) { update: function( loc, placement ) {
this.scales = ( loc instanceof $.Rect ); this.scales = ( loc instanceof $.Rect );
this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height); this.bounds = new $.Rect(loc.x, loc.y, loc.width, loc.height);
// rects are always top-left
this.placement = loc instanceof $.Point ? this.placement = loc instanceof $.Point ?
placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left placement :
$.OverlayPlacement.TOP_LEFT;
} }
}; };

View File

@ -9,19 +9,31 @@ $.Point = function(x, y) {
$.Point.prototype = { $.Point.prototype = {
plus: function( point ) { plus: function( point ) {
return new $.Point(this.x + point.x, this.y + point.y); return new $.Point(
this.x + point.x,
this.y + point.y
);
}, },
minus: function( point ) { minus: function( point ) {
return new $.Point(this.x - point.x, this.y - point.y); return new $.Point(
this.x - point.x,
this.y - point.y
);
}, },
times: function( factor ) { times: function( factor ) {
return new $.Point(this.x * factor, this.y * factor); return new $.Point(
this.x * factor,
this.y * factor
);
}, },
divide: function( factor ) { divide: function( factor ) {
return new $.Point(this.x / factor, this.y / factor); return new $.Point(
this.x / factor,
this.y / factor
);
}, },
negate: function() { negate: function() {
@ -29,8 +41,10 @@ $.Point.prototype = {
}, },
distanceTo: function( point ) { distanceTo: function( point ) {
return Math.sqrt(Math.pow(this.x - point.x, 2) + return Math.sqrt(
Math.pow(this.y - point.y, 2)); Math.pow( this.x - point.x, 2 ) +
Math.pow( this.y - point.y, 2 )
);
}, },
apply: function( func ) { apply: function( func ) {
@ -39,7 +53,8 @@ $.Point.prototype = {
equals: function( point ) { equals: function( point ) {
return ( point instanceof $.Point ) && return ( point instanceof $.Point ) &&
(this.x === point.x) && (this.y === point.y); ( this.x === point.x ) &&
( this.y === point.y );
}, },
toString: function() { toString: function() {

View File

@ -3,117 +3,82 @@
$.Profiler = function() { $.Profiler = function() {
this._midUpdate = false; this.midUpdate = false;
this._numUpdates = 0; this.numUpdates = 0;
this._lastBeginTime = null; this.lastBeginTime = null;
this._lastEndTime = null; this.lastEndTime = null;
this._minUpdateTime = Infinity; this.minUpdateTime = Infinity;
this._avgUpdateTime = 0; this.avgUpdateTime = 0;
this._maxUpdateTime = 0; this.maxUpdateTime = 0;
this._minIdleTime = Infinity; this.minIdleTime = Infinity;
this._avgIdleTime = 0; this.avgIdleTime = 0;
this._maxIdleTime = 0; this.maxIdleTime = 0;
}; };
$.Profiler.prototype = { $.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() { beginUpdate: function() {
if (this._midUpdate) { if (this.midUpdate) {
this.endUpdate(); this.endUpdate();
} }
this._midUpdate = true; this.midUpdate = true;
this._lastBeginTime = new Date().getTime(); this.lastBeginTime = new Date().getTime();
if (this._numUpdates < 1) { if (this.numUpdates < 1) {
return; // this is the first update 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) { if (time < this.minIdleTime) {
this._minIdleTime = time; this.minIdleTime = time;
} }
if (time > this._maxIdleTime) { if (time > this.maxIdleTime) {
this._maxIdleTime = time; this.maxIdleTime = time;
} }
}, },
endUpdate: function() { endUpdate: function() {
if (!this._midUpdate) { if (!this.midUpdate) {
return; return;
} }
this._lastEndTime = new Date().getTime(); this.lastEndTime = new Date().getTime();
this._midUpdate = false; this.midUpdate = false;
var time = this._lastEndTime - this._lastBeginTime; var time = this.lastEndTime - this.lastBeginTime;
this._numUpdates++; this.numUpdates++;
this._avgUpdateTime = (this._avgUpdateTime * (this._numUpdates - 1) + time) / this._numUpdates; this.avgUpdateTime = (this.avgUpdateTime * (this.numUpdates - 1) + time) / this.numUpdates;
if (time < this._minUpdateTime) { if (time < this.minUpdateTime) {
this._minUpdateTime = time; this.minUpdateTime = time;
} }
if (time > this._maxUpdateTime) { if (time > this.maxUpdateTime) {
this._maxUpdateTime = time; this.maxUpdateTime = time;
} }
}, },
clearProfile: function() { clearProfile: function() {
this._midUpdate = false; this.midUpdate = false;
this._numUpdates = 0; this.numUpdates = 0;
this._lastBeginTime = null; this.lastBeginTime = null;
this._lastEndTime = null; this.lastEndTime = null;
this._minUpdateTime = Infinity; this.minUpdateTime = Infinity;
this._avgUpdateTime = 0; this.avgUpdateTime = 0;
this._maxUpdateTime = 0; this.maxUpdateTime = 0;
this._minIdleTime = Infinity; this.minIdleTime = Infinity;
this._avgIdleTime = 0; this.avgIdleTime = 0;
this._maxIdleTime = 0; this.maxIdleTime = 0;
} }
}; };

View File

@ -755,7 +755,7 @@ function updateOnce( viewer ) {
return; return;
} }
viewer.profiler.beginUpdate(); //viewer.profiler.beginUpdate();
var containerSize = $.Utils.getElementSize( viewer.container ); var containerSize = $.Utils.getElementSize( viewer.container );
@ -790,7 +790,7 @@ function updateOnce( viewer ) {
viewer._animating = animated; viewer._animating = animated;
viewer.profiler.endUpdate(); //viewer.profiler.endUpdate();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////