aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 06:51:34 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-09 06:51:34 +0200
commit11fe00e83fe2d5e621fe9b7aeda273b0c0a0cea2 (patch)
tree0cc89cacc755fc3c455a86203c86c82f80afb0d1
parent1bae69b2fdbcf35641d5d4a403cfb6261e34297d (diff)
Profiling setup
-rw-r--r--main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.go b/main.go
index 1ceddf1..a5bde3e 100644
--- a/main.go
+++ b/main.go
@@ -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)