{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-markus/src/babylonian-programming-editor/utils/performance.js"],"names":["Performance","constructor","self","BabylonianPerformance","reset","steps","lastTime","curStep","step","stepName","duration","push","now","stop","performance"],"mappings":";;;;;;;;AAAA,YAAMA,WAAN,CAAkB;;AAEhBC,sBAAc;AACZC,eAAKC,qBAAL,GAA6B,IAA7B;AACA,eAAKC,KAAL;AACD;;AAEDA,gBAAQ;AACN,eAAKC,KAAL,GAAa,EAAb;AACA,eAAKC,QAAL,GAAgB,IAAhB;AACA,eAAKC,OAAL,GAAe,IAAf;AACD;;AAEDC,aAAKC,QAAL,EAAe;AACb;AACA,cAAG,KAAKF,OAAR,EAAiB;AACf;AACA,kBAAMG,WAAW,KAAKA,QAAL,EAAjB;;AAEA;AACA,iBAAKL,KAAL,CAAW,KAAKE,OAAhB,EAAyBI,IAAzB,CAA8BD,QAA9B;AACD;;AAED;AACA,eAAKH,OAAL,GAAeE,QAAf;AACA,cAAG,EAAE,KAAKF,OAAL,IAAgB,KAAKF,KAAvB,CAAH,EAAkC;AAChC,iBAAKA,KAAL,CAAW,KAAKE,OAAhB,IAA2B,EAA3B;AACD;;AAED;AACA,eAAKD,QAAL,GAAgB,KAAKM,GAAL,EAAhB;AACD;;AAEDC,eAAO;AACL;AACA,gBAAMH,WAAW,KAAKA,QAAL,EAAjB;;AAEA,cAAG,CAAC,KAAKH,OAAT,EAAkB;AAChB;AACD;;AAED;AACA,eAAKF,KAAL,CAAW,KAAKE,OAAhB,EAAyBI,IAAzB,CAA8BD,QAA9B;;AAEA,eAAKH,OAAL,GAAe,IAAf;AACD;;AAEDG,mBAAW;AACT,iBAAO,KAAKE,GAAL,KAAa,KAAKN,QAAzB;AACD;;AAEDM,cAAM;AACJ,iBAAOE,YAAYF,GAAZ,EAAP;AACD;;AArDe;;AAyDlB;;;;;;;;;;;;;;;yBACe,IAAIZ,WAAJ,E","file":"performance.js","sourcesContent":["class Performance {\n  \n  constructor() {\n    self.BabylonianPerformance = this;\n    this.reset();\n  }\n  \n  reset() {\n    this.steps = {};\n    this.lastTime = null;\n    this.curStep = null;\n  }\n  \n  step(stepName) {\n    // Log old step if there was one\n    if(this.curStep) {\n      // Get duration\n      const duration = this.duration();\n\n      // Push current duration\n      this.steps[this.curStep].push(duration);\n    }\n    \n    // Add next step\n    this.curStep = stepName\n    if(!(this.curStep in this.steps)) {\n      this.steps[this.curStep] = [];\n    }\n    \n    // Start timer\n    this.lastTime = this.now();\n  }\n  \n  stop() {\n    // Get duration\n    const duration = this.duration();\n    \n    if(!this.curStep) {\n      return;\n    }\n    \n    // Push current duration\n    this.steps[this.curStep].push(duration);\n    \n    this.curStep = null;\n  }\n  \n  duration() {\n    return this.now() - this.lastTime;\n  }\n  \n  now() {\n    return performance.now();\n  }\n  \n}\n\n// Only export as Singleton\nexport default new Performance();"]}