"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const platform = require("./platform.js");
const hasPerformanceNow = platform.globals.performance && typeof platform.globals.performance.now === "function";
class StopWatch {
  constructor(highResolution) {
    this._highResolution = hasPerformanceNow && highResolution;
    this._startTime = this._now();
    this._stopTime = -1;
  }
  static create(highResolution = true) {
    return new StopWatch(highResolution);
  }
  stop() {
    this._stopTime = this._now();
  }
  elapsed() {
    if (this._stopTime !== -1) {
      return this._stopTime - this._startTime;
    }
    return this._now() - this._startTime;
  }
  _now() {
    return this._highResolution ? platform.globals.performance.now() : Date.now();
  }
}
exports.StopWatch = StopWatch;
