mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
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:
parent
2b8fd1941d
commit
dc841a6294
192
openseadragon.js
192
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();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -2227,19 +2227,31 @@ $.Point = function(x, y) {
|
||||
$.Point.prototype = {
|
||||
|
||||
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 ) {
|
||||
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 ) {
|
||||
return new $.Point(this.x * factor, this.y * factor);
|
||||
return new $.Point(
|
||||
this.x * factor,
|
||||
this.y * factor
|
||||
);
|
||||
},
|
||||
|
||||
divide: function( factor ) {
|
||||
return new $.Point(this.x / factor, this.y / factor);
|
||||
return new $.Point(
|
||||
this.x / factor,
|
||||
this.y / factor
|
||||
);
|
||||
},
|
||||
|
||||
negate: function() {
|
||||
@ -2247,8 +2259,10 @@ $.Point.prototype = {
|
||||
},
|
||||
|
||||
distanceTo: function( point ) {
|
||||
return Math.sqrt(Math.pow(this.x - point.x, 2) +
|
||||
Math.pow(this.y - point.y, 2));
|
||||
return Math.sqrt(
|
||||
Math.pow( this.x - point.x, 2 ) +
|
||||
Math.pow( this.y - point.y, 2 )
|
||||
);
|
||||
},
|
||||
|
||||
apply: function( func ) {
|
||||
@ -2257,7 +2271,8 @@ $.Point.prototype = {
|
||||
|
||||
equals: function( point ) {
|
||||
return ( point instanceof $.Point ) &&
|
||||
(this.x === point.x) && (this.y === point.y);
|
||||
( 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;
|
||||
}
|
||||
};
|
||||
|
||||
@ -3195,7 +3175,6 @@ $.Tile.prototype = {
|
||||
|
||||
(function( $ ){
|
||||
|
||||
|
||||
$.OverlayPlacement = {
|
||||
CENTER: 0,
|
||||
TOP_LEFT: 1,
|
||||
@ -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;
|
||||
};
|
||||
@ -3276,9 +3266,11 @@ $.Tile.prototype = {
|
||||
}
|
||||
},
|
||||
drawHTML: function( container ) {
|
||||
var elmt = this.elmt;
|
||||
var style = this.style;
|
||||
var scales = this.scales;
|
||||
var elmt = this.elmt,
|
||||
style = this.style,
|
||||
scales = this.scales,
|
||||
position,
|
||||
size;
|
||||
|
||||
if ( elmt.parentNode != container ) {
|
||||
container.appendChild( elmt );
|
||||
@ -3288,8 +3280,8 @@ $.Tile.prototype = {
|
||||
this.size = $.Utils.getElementSize( elmt );
|
||||
}
|
||||
|
||||
var position = this.position;
|
||||
var size = this.size;
|
||||
position = this.position;
|
||||
size = this.size;
|
||||
|
||||
this.adjust( position, size );
|
||||
|
||||
@ -3308,8 +3300,10 @@ $.Tile.prototype = {
|
||||
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; // rects are always top-left
|
||||
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) {
|
||||
|
@ -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) {
|
||||
|
@ -1 +0,0 @@
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
(function( $ ){
|
||||
|
||||
|
||||
$.OverlayPlacement = {
|
||||
CENTER: 0,
|
||||
TOP_LEFT: 1,
|
||||
@ -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;
|
||||
};
|
||||
@ -82,9 +92,11 @@
|
||||
}
|
||||
},
|
||||
drawHTML: function( container ) {
|
||||
var elmt = this.elmt;
|
||||
var style = this.style;
|
||||
var scales = this.scales;
|
||||
var elmt = this.elmt,
|
||||
style = this.style,
|
||||
scales = this.scales,
|
||||
position,
|
||||
size;
|
||||
|
||||
if ( elmt.parentNode != container ) {
|
||||
container.appendChild( elmt );
|
||||
@ -94,8 +106,8 @@
|
||||
this.size = $.Utils.getElementSize( elmt );
|
||||
}
|
||||
|
||||
var position = this.position;
|
||||
var size = this.size;
|
||||
position = this.position;
|
||||
size = this.size;
|
||||
|
||||
this.adjust( position, size );
|
||||
|
||||
@ -114,8 +126,10 @@
|
||||
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; // rects are always top-left
|
||||
placement :
|
||||
$.OverlayPlacement.TOP_LEFT;
|
||||
}
|
||||
|
||||
};
|
||||
|
29
src/point.js
29
src/point.js
@ -9,19 +9,31 @@ $.Point = function(x, y) {
|
||||
$.Point.prototype = {
|
||||
|
||||
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 ) {
|
||||
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 ) {
|
||||
return new $.Point(this.x * factor, this.y * factor);
|
||||
return new $.Point(
|
||||
this.x * factor,
|
||||
this.y * factor
|
||||
);
|
||||
},
|
||||
|
||||
divide: function( factor ) {
|
||||
return new $.Point(this.x / factor, this.y / factor);
|
||||
return new $.Point(
|
||||
this.x / factor,
|
||||
this.y / factor
|
||||
);
|
||||
},
|
||||
|
||||
negate: function() {
|
||||
@ -29,8 +41,10 @@ $.Point.prototype = {
|
||||
},
|
||||
|
||||
distanceTo: function( point ) {
|
||||
return Math.sqrt(Math.pow(this.x - point.x, 2) +
|
||||
Math.pow(this.y - point.y, 2));
|
||||
return Math.sqrt(
|
||||
Math.pow( this.x - point.x, 2 ) +
|
||||
Math.pow( this.y - point.y, 2 )
|
||||
);
|
||||
},
|
||||
|
||||
apply: function( func ) {
|
||||
@ -39,7 +53,8 @@ $.Point.prototype = {
|
||||
|
||||
equals: function( point ) {
|
||||
return ( point instanceof $.Point ) &&
|
||||
(this.x === point.x) && (this.y === point.y);
|
||||
( this.x === point.x ) &&
|
||||
( this.y === point.y );
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
|
115
src/profiler.js
115
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user