fileoverview declare let process ; /**
 * All the chronometer implementations (hrtime, window.performance, and date:
 */ const implementations = { node : { name : "hrtime" , _startTime : 0 , _stopTime : undefined as any [ ] | undefined , stop : ( ) => { } , _start ( ) { this . _startTime = process . hrtime ( ) ; } , _stop ( ) { this . _stopTime = process . hrtime ( this . _startTime ) ; } , _elapsedSec ( ) { if ( this . _stopTime === undefined ) { this . stop ( ) ; } return ( this . _stopTime ! [ 0 ] as number ) + ( this . _stopTime ! [ 1 ] as number ) / 1000000000 ; } , _elapsedMilliSec ( ) { if ( this . _stopTime === undefined ) { this . stop ( ) ; } return this . _stopTime ! [ 0 ] * 1000 + this . _stopTime ! [ 1 ] / 1000000 ; } , _elapsedMicroSec ( ) { if ( this . _stopTime === undefined ) { this . stop ( ) ; } return this . _stopTime ! [ 0 ] * 1000000 + this . _stopTime ! [ 1 ] / 1000 ; } } , performance : { name : "window.performance" , _startTime : 0 , _stopTime : 0 , stop : ( ) => { } , elapsedMilliSec : ( ) => 0 , _start ( ) { this . _startTime = window . performance . now ( ) ; } , _stop ( ) { this . _stopTime = window . performance . now ( ) ; } , _elapsedSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return this . elapsedMilliSec ( ) / 1000 ; } , _elapsedMilliSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return this . _stopTime - this . _startTime ; } , _elapsedMicroSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return this . elapsedMilliSec ( ) * 1000 ; } } , date : { name : "date" , _startTime : new Date ( ) , _stopTime : undefined as Date | undefined , stop : ( ) => { } , elapsedMilliSec : ( ) => 0 , _start ( ) { this . _startTime = new Date ( ) ; } , _stop ( ) { this . _stopTime = new Date ( ) ; } , _elapsedSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return this . elapsedMilliSec ( ) / 1000 ; } , _elapsedMilliSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return ( this . _stopTime as Date ) . getTime ( ) - this . _startTime . getTime ( ) ; } , _elapsedMicroSec ( ) { if ( ! this . _stopTime ) { this . stop ( ) ; } return this . elapsedMilliSec ( ) * 1000 ; } } } ; let impl ; if ( typeof process !== "undefined" && typeof process . hrtime !== "undefined" ) { impl = implementations . node ; } else if ( typeof window !== "undefined" && typeof window . performance !== "undefined" && typeof window . performance . now !== "undefined" ) { impl = implementations . performance ; } else { impl = implementations . date ; } /**
 * Creates and starts a new Chronometer.
 */ export class Chronometer { constructor ( ) { this . start ( ) ; } /**
     * Sets the chronometer start time.
     */ start ( ) { return impl . _start . call ( this ) ; } /**
     * Stops the chronometer. Stopped chronometers can be reused by calling  Chronometer . start again.
     *
     *  returns stop ( ) { impl . _stop . call ( this ) ; return this ; } returns How many microseconds have elapsed between the last call to  Chronometer . start *   (or the chronometer creation), and  Chronometer . stop . Implementations that are not precise
     *   enough may return "elapsedMilliSec() * 1000". Measuring elapsed time causes the chronometer
     *   to be stopped if required (if the chrono is not stopped when this method is called).
      elapsedMicroSec ( ) { return impl . _elapsedMicroSec . call ( this ) ; } returns How many milliseconds have elapsed between the last call to  Chronometer . start *   (or the chronometer creation), and  Chronometer . stop . Measuring elapsed time causes the
     *   chronometer to be stopped if required (if the chrono is not stopped when this method is
     *   called).
      elapsedMilliSec ( ) { return impl . _elapsedMilliSec . call ( this ) ; } returns How many seconds have elapsed between the last call to  Chronometer . start *   (or the chronometer creation), and  Chronometer . stop . Measuring elapsed time causes the
     *   chronometer to be stopped if required (if the chrono is not stopped when this method is
     *   called).
      elapsedSec ( ) { return impl . _elapsedSec . call ( this ) ; } param promiseFn returns static async timePromise < T > ( promiseFn ) { const chrono = new Chronometer ( ) ; const result = await promiseFn ( ) ; chrono . stop ( ) ; return { chrono , result } ; } }