* 打印统计信息到日志
()
| 323 | * 打印统计信息到日志 |
| 324 | */ |
| 325 | private logStats(): void { |
| 326 | const stats = this.getStats(); |
| 327 | |
| 328 | logger.info('=== ECS Debug Stats ==='); |
| 329 | logger.info(`Total Entities: ${stats.totalEntities}`); |
| 330 | logger.info(`Total Systems: ${stats.totalSystems}`); |
| 331 | logger.info(`Scenes: ${stats.scenes.length}`); |
| 332 | |
| 333 | for (const scene of stats.scenes) { |
| 334 | logger.info(`\n[Scene: ${scene.name}]`); |
| 335 | logger.info(` Entities: ${scene.entityCount}`); |
| 336 | logger.info(` Systems: ${scene.systems.length}`); |
| 337 | |
| 338 | for (const system of scene.systems) { |
| 339 | const perfStr = system.performance |
| 340 | ? ` | Avg: ${system.performance.avgExecutionTime.toFixed(2)}ms, Max: ${system.performance.maxExecutionTime.toFixed(2)}ms` |
| 341 | : ''; |
| 342 | logger.info( |
| 343 | ` - ${system.name} (${system.enabled ? 'enabled' : 'disabled'}) | Entities: ${system.entityCount}${perfStr}` |
| 344 | ); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | logger.info('========================\n'); |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * 导出调试数据为 JSON |