* 获取全局池统计信息的格式化字符串 * @returns 格式化的统计信息字符串
()
| 240 | * @returns 格式化的统计信息字符串 |
| 241 | */ |
| 242 | public static getGlobalStatsString(): string { |
| 243 | const stats = this.getAllPoolStats(); |
| 244 | const lines: string[] = ['=== Object Pool Global Statistics ===', '']; |
| 245 | |
| 246 | if (Object.keys(stats).length === 0) { |
| 247 | lines.push('No pools registered'); |
| 248 | return lines.join('\n'); |
| 249 | } |
| 250 | |
| 251 | for (const [typeName, stat] of Object.entries(stats)) { |
| 252 | lines.push(`${typeName}:`); |
| 253 | lines.push(` Size: ${stat.size}/${stat.maxSize}`); |
| 254 | lines.push(` Hit Rate: ${(stat.hitRate * 100).toFixed(1)}%`); |
| 255 | lines.push(` Total Created: ${stat.totalCreated}`); |
| 256 | lines.push(` Total Obtained: ${stat.totalObtained}`); |
| 257 | lines.push(` Memory: ${(stat.estimatedMemoryUsage / 1024).toFixed(1)} KB`); |
| 258 | lines.push(''); |
| 259 | } |
| 260 | |
| 261 | return lines.join('\n'); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * 更新命中率 |
nothing calls this directly
no test coverage detected