mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-13 00:34:04 +02:00
Re-factor the StatTimer class to track started times in a private Map
This commit is contained in:
parent
a9e439bce1
commit
522f5f85b9
@ -417,28 +417,28 @@ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
|
||||
}
|
||||
|
||||
class StatTimer {
|
||||
started = Object.create(null);
|
||||
#started = new Map();
|
||||
|
||||
times = [];
|
||||
|
||||
time(name) {
|
||||
if (name in this.started) {
|
||||
if (this.#started.has(name)) {
|
||||
warn(`Timer is already running for ${name}`);
|
||||
}
|
||||
this.started[name] = Date.now();
|
||||
this.#started.set(name, Date.now());
|
||||
}
|
||||
|
||||
timeEnd(name) {
|
||||
if (!(name in this.started)) {
|
||||
if (!this.#started.has(name)) {
|
||||
warn(`Timer has not been started for ${name}`);
|
||||
}
|
||||
this.times.push({
|
||||
name,
|
||||
start: this.started[name],
|
||||
start: this.#started.get(name),
|
||||
end: Date.now(),
|
||||
});
|
||||
// Remove timer from started so it can be called again.
|
||||
delete this.started[name];
|
||||
this.#started.delete(name);
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user