| 44 | this.logger.info(name + ': ' + this._timeStamps[name]); |
| 45 | } |
| 46 | timeLog(name: string) { |
| 47 | if (this._timeStamps[name]) { |
| 48 | const timeStamp = +new Date() - +this._timeStamps[name]; |
| 49 | const seconds = Math.floor(timeStamp / 1000); |
| 50 | const minutes = Math.floor(seconds / 60); |
| 51 | const hours = Math.floor(minutes / 60); |
| 52 | let timeStr = name + ':'; |
| 53 | if (hours >= 1) { |
| 54 | timeStr += ' ' + hours + 'h'; |
| 55 | } |
| 56 | if (minutes >= 1) { |
| 57 | timeStr += ' ' + minutes + 'm'; |
| 58 | } |
| 59 | if (seconds >= 1) { |
| 60 | timeStr += ' ' + seconds + 's'; |
| 61 | } |
| 62 | if (timeStamp >= 1) { |
| 63 | timeStr += ' ' + (timeStamp % 1000) + 'ms'; |
| 64 | } |
| 65 | this.logger.info(timeStr); |
| 66 | return; |
| 67 | } |
| 68 | this.logger.warn(name + ' is not found'); |
| 69 | } |
| 70 | timeEnd(name: string) { |
| 71 | this.timeLog(name); |
| 72 | delete this._timeStamps[name]; |