Skip to content

Commit

Permalink
fix units symbol for bytes in stats printing and tests (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange-42 authored Feb 21, 2023
1 parent e154266 commit 81f8943
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog

## [[unpublished]](https://github.com/mlange-42/arche/compare/v0.4.0...main)
## [[unpublished]](https://github.com/mlange-42/arche/compare/v0.4.1...main)

Nothing

## [[v0.4.1]](https://github.com/mlange-42/arche/compare/v0.4.0...v0.4.1)

## Bugfixes

* Fix units symbol for bytes from `b` to `B` in string formatting of world statistics (#111)

## Other

Expand Down
11 changes: 11 additions & 0 deletions ecs/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestQuery(t *testing.T) {
posID := ComponentID[position](&w)
rotID := ComponentID[rotation](&w)
velID := ComponentID[velocity](&w)
s0ID := ComponentID[testStruct0](&w)

e0 := w.NewEntity()
e1 := w.NewEntity()
Expand Down Expand Up @@ -94,4 +95,14 @@ func TestQuery(t *testing.T) {
cnt++
}
assert.Equal(t, 1, cnt)

filter = All(rotID, s0ID).Without()
q = w.Query(&filter)

cnt = 0
for q.Next() {
_ = q.Entity()
cnt++
}
assert.Equal(t, 0, cnt)
}
4 changes: 2 additions & 2 deletions ecs/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *WorldStats) String() string {
b := strings.Builder{}

fmt.Fprintf(
&b, "World -- Components: %d, Archetypes: %d, Memory: %.1f kb, Locked: %t\n",
&b, "World -- Components: %d, Archetypes: %d, Memory: %.1f kB, Locked: %t\n",
s.ComponentCount, len(s.Archetypes), float64(s.Memory)/1024.0, s.Locked,
)

Expand Down Expand Up @@ -83,7 +83,7 @@ func (s *ArchetypeStats) String() string {
typeNames[i] = tp.Name()
}
return fmt.Sprintf(
"Archetype -- Components: %2d, Entities: %6d, Capacity: %6d, Memory: %7.1f kb\n Components: %s\n",
"Archetype -- Components: %2d, Entities: %6d, Capacity: %6d, Memory: %7.1f kB\n Components: %s\n",
s.Components, s.Size, s.Capacity, float64(s.Memory)/1024.0, strings.Join(typeNames, ", "),
)
}
4 changes: 2 additions & 2 deletions ecs/world_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ func TestTypeSizes(t *testing.T) {

func printTypeSize[T any]() {
tp := reflect.TypeOf((*T)(nil)).Elem()
fmt.Printf("%16s: %5db\n", tp.Name(), tp.Size())
fmt.Printf("%16s: %5d B\n", tp.Name(), tp.Size())
}

func printTypeSizeName[T any](name string) {
tp := reflect.TypeOf((*T)(nil)).Elem()
fmt.Printf("%16s: %5db\n", name, tp.Size())
fmt.Printf("%16s: %5d B\n", name, tp.Size())
}

0 comments on commit 81f8943

Please sign in to comment.