MCPcopy Create free account
hub / github.com/esengine/esengine / getStats

Method getStats

packages/core/src/ECS/Core/QuerySystem.ts:968–1021  ·  view source on GitHub ↗

* 获取系统统计信息 * * 返回查询系统的详细统计信息,包括实体数量、索引状态、 * 查询性能统计等,用于性能监控和调试。 * * @returns 系统统计信息对象

()

Source from the content-addressed store, hash-verified

966 * @returns 系统统计信息对象
967 */
968 public getStats(): {
969 entityCount: number;
970 indexStats: {
971 componentIndexSize: number;
972 tagIndexSize: number;
973 nameIndexSize: number;
974 };
975 queryStats: {
976 totalQueries: number;
977 cacheHits: number;
978 indexHits: number;
979 linearScans: number;
980 archetypeHits: number;
981 dirtyChecks: number;
982 cacheHitRate: string;
983 };
984 optimizationStats: {
985 archetypeSystem: any;
986 };
987 cacheStats: {
988 size: number;
989 hitRate: string;
990 };
991 } {
992 return {
993 entityCount: this._entities.length,
994 indexStats: {
995 componentIndexSize: this._archetypeSystem.getAllArchetypes().length,
996 tagIndexSize: this._entityIndex.byTag.size,
997 nameIndexSize: this._entityIndex.byName.size
998 },
999 queryStats: {
1000 ...this._queryStats,
1001 cacheHitRate:
1002 this._queryStats.totalQueries > 0
1003 ? ((this._queryStats.cacheHits / this._queryStats.totalQueries) * 100).toFixed(2) + '%'
1004 : '0%'
1005 },
1006 optimizationStats: {
1007 archetypeSystem: this._archetypeSystem.getAllArchetypes().map((a) => ({
1008 id: a.id,
1009 componentTypes: a.componentTypes.map((t) => getComponentTypeName(t)),
1010 entityCount: a.entities.size
1011 }))
1012 },
1013 cacheStats: {
1014 size: this._reactiveQueries.size,
1015 hitRate:
1016 this._queryStats.totalQueries > 0
1017 ? ((this._queryStats.cacheHits / this._queryStats.totalQueries) * 100).toFixed(2) + '%'
1018 : '0%'
1019 }
1020 };
1021 }
1022
1023 /**
1024 * 获取实体所属的原型信息

Callers

nothing calls this directly

Calls 3

getComponentTypeNameFunction · 0.50
getAllArchetypesMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected