mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +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
244
openseadragon.js
244
openseadragon.js
@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -2226,38 +2226,53 @@ $.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() {
|
||||||
return new $.Point(-this.x, -this.y);
|
return new $.Point( -this.x, -this.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
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 ) {
|
||||||
return new $.Point(func(this.x), func(this.y));
|
return new $.Point( func(this.x), func(this.y) );
|
||||||
},
|
},
|
||||||
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
@ -3275,41 +3265,45 @@ $.Tile.prototype = {
|
|||||||
style.height = "";
|
style.height = "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scales) {
|
if ( !scales ) {
|
||||||
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 );
|
||||||
|
|
||||||
position = position.apply(Math.floor);
|
position = position.apply( Math.floor );
|
||||||
size = size.apply(Math.ceil);
|
size = size.apply( Math.ceil );
|
||||||
|
|
||||||
style.left = position.x + "px";
|
style.left = position.x + "px";
|
||||||
style.top = position.y + "px";
|
style.top = position.y + "px";
|
||||||
style.position = "absolute";
|
style.position = "absolute";
|
||||||
|
|
||||||
if (scales) {
|
if ( scales ) {
|
||||||
style.width = size.x + "px";
|
style.width = size.x + "px";
|
||||||
style.height = size.y + "px";
|
style.height = size.y + "px";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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);
|
||||||
this.placement = loc instanceof $.Point ?
|
// rects are always top-left
|
||||||
placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left
|
this.placement = loc instanceof $.Point ?
|
||||||
|
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) {
|
||||||
|
@ -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) {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -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;
|
||||||
};
|
};
|
||||||
@ -81,41 +91,45 @@
|
|||||||
style.height = "";
|
style.height = "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scales) {
|
if ( !scales ) {
|
||||||
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 );
|
||||||
|
|
||||||
position = position.apply(Math.floor);
|
position = position.apply( Math.floor );
|
||||||
size = size.apply(Math.ceil);
|
size = size.apply( Math.ceil );
|
||||||
|
|
||||||
style.left = position.x + "px";
|
style.left = position.x + "px";
|
||||||
style.top = position.y + "px";
|
style.top = position.y + "px";
|
||||||
style.position = "absolute";
|
style.position = "absolute";
|
||||||
|
|
||||||
if (scales) {
|
if ( scales ) {
|
||||||
style.width = size.x + "px";
|
style.width = size.x + "px";
|
||||||
style.height = size.y + "px";
|
style.height = size.y + "px";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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);
|
||||||
this.placement = loc instanceof $.Point ?
|
// rects are always top-left
|
||||||
placement : $.OverlayPlacement.TOP_LEFT; // rects are always top-left
|
this.placement = loc instanceof $.Point ?
|
||||||
|
placement :
|
||||||
|
$.OverlayPlacement.TOP_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
49
src/point.js
49
src/point.js
@ -8,38 +8,53 @@ $.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() {
|
||||||
return new $.Point(-this.x, -this.y);
|
return new $.Point( -this.x, -this.y );
|
||||||
},
|
},
|
||||||
|
|
||||||
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 ) {
|
||||||
return new $.Point(func(this.x), func(this.y));
|
return new $.Point( func(this.x), func(this.y) );
|
||||||
},
|
},
|
||||||
|
|
||||||
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() {
|
||||||
|
115
src/profiler.js
115
src/profiler.js
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user