Browse Source

web based profiler

Harry de Boer 10 years ago
parent
commit
c19106333c
2 changed files with 4 additions and 7 deletions
  1. 1 0
      .gitignore
  2. 3 7
      main.go

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@
 .idea/
 battlecamp-go-boardgenerator
 *.log
+*.prof

+ 3 - 7
main.go

@@ -3,8 +3,9 @@ package main
 
 import (
 	"log"
+	"net/http"
+	_ "net/http/pprof"
 	"os"
-	"runtime/pprof"
 
 	"battlecamp-go-server/flag"
 	"battlecamp-go-server/gameserver"
@@ -36,11 +37,6 @@ func initCliFlags() {
 	flag.ParseFlags()
 
 	if *flag.CpuProfile != "" {
-		f, err := os.Create(*flag.CpuProfile)
-		if err != nil {
-			log.Fatal(err)
-		}
-		pprof.StartCPUProfile(f)
-		defer pprof.StopCPUProfile()
+		log.Println(http.ListenAndServe("localhost:6060", nil))
 	}
 }