add some useful logs to LoadAndPrepare
This commit is contained in:
parent
5116a10303
commit
0af38d6d91
1 changed files with 8 additions and 0 deletions
|
@ -6,10 +6,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
)
|
)
|
||||||
|
@ -243,6 +245,7 @@ func walk(component, parent interface{}, visit func(component, parent interface{
|
||||||
// LoadAndPrepare must be called before any calls to Component or Query.
|
// LoadAndPrepare must be called before any calls to Component or Query.
|
||||||
func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
||||||
// Load all the Loaders.
|
// Load all the Loaders.
|
||||||
|
startLoad := time.Now()
|
||||||
if err := Walk(g, func(c, _ interface{}) error {
|
if err := Walk(g, func(c, _ interface{}) error {
|
||||||
l, ok := c.(Loader)
|
l, ok := c.(Loader)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -252,8 +255,10 @@ func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Printf("finished loading in %v", time.Since(startLoad))
|
||||||
|
|
||||||
// Build the component databases
|
// Build the component databases
|
||||||
|
startBuild := time.Now()
|
||||||
g.dbmu.Lock()
|
g.dbmu.Lock()
|
||||||
g.byID = make(map[string]Identifier)
|
g.byID = make(map[string]Identifier)
|
||||||
g.byAB = make(map[abKey]map[interface{}]struct{})
|
g.byAB = make(map[abKey]map[interface{}]struct{})
|
||||||
|
@ -262,13 +267,16 @@ func (g *Game) LoadAndPrepare(assets fs.FS) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
g.dbmu.Unlock()
|
g.dbmu.Unlock()
|
||||||
|
log.Printf("finished building db in %v", time.Since(startBuild))
|
||||||
|
|
||||||
// Prepare all the Preppers
|
// Prepare all the Preppers
|
||||||
|
startPrep := time.Now()
|
||||||
for p := range g.Query(g.Ident(), PrepperType) {
|
for p := range g.Query(g.Ident(), PrepperType) {
|
||||||
if err := p.(Prepper).Prepare(g); err != nil {
|
if err := p.(Prepper).Prepare(g); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Printf("finished preparing in %v", time.Since(startPrep))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue