From c4024e30c29eb5c83c680c2af9c64188ef89a62a Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 22 Jul 2020 15:13:13 -0700 Subject: [PATCH] debug: Convert IterationProfiler to an ES6 class. Signed-off-by: Anders Kaseorg --- static/js/debug.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/static/js/debug.js b/static/js/debug.js index 3aab52f2da..6b9a75c198 100644 --- a/static/js/debug.js +++ b/static/js/debug.js @@ -98,15 +98,13 @@ export function check_duplicate_ids() { * The _rest_of_iteration section is the region of the iteration body * after section b. */ -export function IterationProfiler() { - this.sections = new Map(); - this.last_time = window.performance.now(); -} +export class IterationProfiler { + sections = new Map(); + last_time = window.performance.now(); -IterationProfiler.prototype = { iteration_start() { this.section("_iteration_overhead"); - }, + } iteration_stop() { const now = window.performance.now(); @@ -118,13 +116,13 @@ IterationProfiler.prototype = { ); } this.last_time = now; - }, + } section(label) { const now = window.performance.now(); this.sections.set(label, (this.sections.get(label) || 0) + (now - this.last_time)); this.last_time = now; - }, + } done() { this.section("_iteration_overhead"); @@ -132,5 +130,5 @@ IterationProfiler.prototype = { for (const [prop, cost] of this.sections) { console.log(prop, cost); } - }, -}; + } +}