export default function perf ( label ) { return new PerfInstance ( label ) ; } export class PerfInstance { protected stepNum : number = 0 ; protected stepTs : number ; constructor ( protected label ) { this . step ( 'Init' ) ; } step ( label = 'Step' ) { const last = this . stepTs ; const now = performance . now ( ) ; this . stepNum ++ ; this . stepTs = now ; console . info ( `${ this . label } - ${ label } - Step ${ this . stepNum }` , last ? `- ${ now - last }ms` : '' ) ; } end ( ) { this . step ( 'End' ) ; } }