// Package stats provides the structs returned by ecs.World.Stats().
package statsimport ()// World statistics.typeWorldstruct {// Component types, indexed by component ID. // Note that this field is excluded from JSON marshalling and un-marshalling. // Use ComponentTypeNames instead. ComponentTypes []reflect.Type`json:"-"`// Component type names, indexed by component ID. ComponentTypeNames []string// Archetype statistics. Archetypes []Archetype// Entity statistics. Entities Entities// Memory reserved for entities and components, in bytes. Memory int// Memory actually used for alive entities and their components components, in bytes. MemoryUsed int// Number of cached filters. CachedFilters int// Number of registered observers. Observers int// Locked state of the world. Locked bool}// Entities statistics.typeEntitiesstruct {// Currently used/alive entities. Used int// Recycled/available entities. Recycled int// Current total number of entities in the pool (used + recycled). Total int// Current capacity of entity pool and entity list. Capacity int}// Archetype statistics.typeArchetypestruct {// Component IDs. ComponentIDs []uint8// Component types for ComponentIDs. // Note that this field is excluded from JSON marshalling and un-marshalling. // Use ComponentTypeNames instead. ComponentTypes []reflect.Type`json:"-"`// Component type names for ComponentIDs. ComponentTypeNames []string// Table statistics. Tables []Table// Number of entities in the tables of this archetype. Size int// Sum of capacity of the tables in this archetype. Capacity int// Number of relation components in the archetype. NumRelations int// Memory reserved for entities and components, in bytes. Memory int// Memory actually used for alive entities and their components components, in bytes. MemoryUsed int// Memory for components per entity, in bytes. MemoryPerEntity int// Number of free tables. FreeTables int}// Table statistics.typeTablestruct {// Number of entities in the table. Size int// Capacity of the table. Capacity int// Memory reserved for entities and components, in bytes. Memory int// Memory actually used for alive entities and their components components, in bytes. MemoryUsed int}func ( *World) () string { := strings.Builder{}fmt.Fprintf( &, "World -- Components: %d, Archetypes: %d, Filters: %d, Observers: %d, Memory: %.1f/%.1f kB, Locked: %t\n",len(.ComponentTypeNames), len(.Archetypes), .CachedFilters, .Observers, float64(.MemoryUsed)/1024.0, float64(.Memory)/1024.0, .Locked, )fmt.Fprintf(&, " Components: %s\n", strings.Join(.ComponentTypeNames, ", "))fmt.Fprint(&, .Entities.String())for := range .Archetypes {fmt.Fprint(&, .Archetypes[].String()) }return .String()}func ( *Entities) () string {returnfmt.Sprintf("Entities -- Used: %d, Recycled: %d, Total: %d, Capacity: %d\n", .Used, .Recycled, .Total, .Capacity)}func ( *Archetype) () string {returnfmt.Sprintf("Archetype -- Tables: %4d, Comps: %2d, Entities: %6d, Cap: %6d, Mem: %7.1f kB, Per entity: %4d B\n Components: %s\n",len(.Tables), len(.ComponentIDs), .Size, .Capacity, float64(.Memory)/1024.0, .MemoryPerEntity, strings.Join(.ComponentTypeNames, ", "), )}func ( *Table) () string {returnfmt.Sprintf("Table -- Entities: %6d, Cap: %6d, Mem: %7.1f kB\n", .Size, .Capacity, float64(.Memory)/1024.0)}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.