diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-09 06:51:34 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2025-07-09 06:51:34 +0200 |
| commit | 11fe00e83fe2d5e621fe9b7aeda273b0c0a0cea2 (patch) | |
| tree | 0cc89cacc755fc3c455a86203c86c82f80afb0d1 | |
| parent | 1bae69b2fdbcf35641d5d4a403cfb6261e34297d (diff) | |
Profiling setup
| -rw-r--r-- | main.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -10,6 +10,7 @@ import ( _ "image/jpeg" "math" "os" + "runtime/pprof" "time" "github.com/hajimehoshi/ebiten/v2" @@ -203,6 +204,15 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeigh } func main() { + for _, arg := range os.Args { + if arg == "--profile" { + f, err := os.Create("cpu.prof") + kcore.Expect(err, "could not create CPU profile") + defer f.Close() + kcore.Expect(pprof.StartCPUProfile(f), "could not start CPU profile") + defer pprof.StopCPUProfile() + } + } logHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}) slog.SetDefault(slog.New(logHandler)) ebiten.SetWindowSize(640, 480) |
