aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-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)