diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-03 11:58:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 11:58:12 -0400 |
commit | d776125eade1683cec6b9b500ae8d37af03e43af (patch) | |
tree | 824598d37b2c3d5c7073e0a56b257cef770250ee | |
parent | 897d85d1ac82dd2e757eefe99e4a6ac3e5e0c486 (diff) |
Refactor timer privates (#639)
* Make Timer.current public
* Make _indentString non-static
-rw-r--r-- | ext/mixed/js/timer.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/mixed/js/timer.js b/ext/mixed/js/timer.js index 30408e93..4fb9dbd1 100644 --- a/ext/mixed/js/timer.js +++ b/ext/mixed/js/timer.js @@ -22,12 +22,12 @@ class Timer { this.parent = null; this.sample(name); - const current = Timer._current; + const current = Timer.current; if (current !== null) { current.samples[current.samples.length - 1].children.push(this); this.parent = current; } - Timer._current = this; + Timer.current = this; } sample(name) { @@ -42,7 +42,7 @@ class Timer { complete(skip) { this.sample('complete'); - Timer._current = this.parent; + Timer.current = this.parent; if (this.parent === null) { if (!skip) { console.log(this.toString()); @@ -67,7 +67,7 @@ class Timer { const name = this.samples[0].name; const duration = this.samples[this.samples.length - 1].time - this.samples[0].time; const extensionName = chrome.runtime.getManifest().name; - return `${name} took ${duration.toFixed(8)}ms [${extensionName}]` + Timer._indentString(this.getSampleString(), indent); + return `${name} took ${duration.toFixed(8)}ms [${extensionName}]` + this._indentString(this.getSampleString(), indent); } getSampleString() { @@ -80,16 +80,16 @@ class Timer { const sampleDuration = this.samples[i + 1].time - sample.time; message += `\nSample[${i}] took ${sampleDuration.toFixed(8)}ms (${((sampleDuration / duration) * 100.0).toFixed(1)}%) [${sample.name}]`; for (const child of sample.children) { - message += Timer._indentString(child.getSampleString(), indent); + message += this._indentString(child.getSampleString(), indent); } } return message; } - static _indentString(message, indent) { + _indentString(message, indent) { return message.replace(/\n/g, `\n${indent}`); } } -Timer._current = null; +Timer.current = null; |