mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Update stats to use the new pdfBug panel.
This commit is contained in:
parent
de18d1623b
commit
e07505ff8d
5 changed files with 112 additions and 63 deletions
14
src/util.js
14
src/util.js
|
@ -416,26 +416,26 @@ var Promise = (function PromiseClosure() {
|
|||
return Promise;
|
||||
})();
|
||||
|
||||
var Bench = (function BenchClosure() {
|
||||
var StatTimer = (function StatTimerClosure() {
|
||||
function rpad(str, pad, length) {
|
||||
while (str.length < length)
|
||||
str += pad;
|
||||
return str;
|
||||
}
|
||||
function Bench() {
|
||||
function StatTimer() {
|
||||
this.started = {};
|
||||
this.times = [];
|
||||
this.enabled = true;
|
||||
}
|
||||
Bench.prototype = {
|
||||
time: function benchTime(name) {
|
||||
StatTimer.prototype = {
|
||||
time: function statTimerTime(name) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
if (name in this.started)
|
||||
throw 'Timer is already running for ' + name;
|
||||
this.started[name] = Date.now();
|
||||
},
|
||||
timeEnd: function benchTimeEnd(name) {
|
||||
timeEnd: function statTimerTimeEnd(name) {
|
||||
if (!this.enabled)
|
||||
return;
|
||||
if (!(name in this.started))
|
||||
|
@ -448,7 +448,7 @@ var Bench = (function BenchClosure() {
|
|||
// Remove timer from started so it can be called again.
|
||||
delete this.started[name];
|
||||
},
|
||||
toString: function benchToString() {
|
||||
toString: function statTimerToString() {
|
||||
var times = this.times;
|
||||
var out = '';
|
||||
// Find the longest name for padding purposes.
|
||||
|
@ -466,5 +466,5 @@ var Bench = (function BenchClosure() {
|
|||
return out;
|
||||
}
|
||||
};
|
||||
return Bench;
|
||||
return StatTimer;
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue