(idx?: number)
| 98 | } |
| 99 | |
| 100 | toString(idx?: number) { |
| 101 | if (idx !== undefined) { |
| 102 | let i = idx; |
| 103 | if (idx < 0) { |
| 104 | i = this.breakPoints.length + idx; |
| 105 | } |
| 106 | const label = this.breakPoints?.[i]["label"]; |
| 107 | const indent = this.breakPoints?.[i]["indent"]; |
| 108 | let millsec = 0; |
| 109 | if (i >= 1) { |
| 110 | millsec = |
| 111 | Math.round( |
| 112 | (this.breakPoints?.[i]["fakeTimeMilli"] - |
| 113 | this.breakPoints?.[i - 1]["fakeTimeMilli"]) * |
| 114 | 10 |
| 115 | ) / 10.0; |
| 116 | } |
| 117 | let res = `${" ".repeat(indent)}[${label}]: ${millsec}ms`; |
| 118 | if (this.breakPoints[i].hasOwnProperty("size")) { |
| 119 | const size = this.breakPoints[i].size as number; |
| 120 | res += `, size=${size}`; |
| 121 | } |
| 122 | return res; |
| 123 | } |
| 124 | |
| 125 | if (this.breakPoints.length === 0) { |
| 126 | return "nothing in profiler"; |
| 127 | } |
| 128 | |
| 129 | let res = `[startTime]: ${unixTimeToStr(this.startTime)}`; |
| 130 | for (let i = 0; i < this.breakPoints.length; ++i) { |
| 131 | if (i === 0) { |
| 132 | res += `\n[${this.breakPoints[i]["label"]}]: start`; |
| 133 | } else { |
| 134 | res += `\n${this.toString(i)}`; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return res; |
| 139 | } |
| 140 | |
| 141 | async save( |
| 142 | db: InternalDBs, |
no test coverage detected