Example #1
0
File: main.go Project: gbember/gt
func main() {
	log.SetFlags(log.Lshortfile | log.Ldate)

	meshFileName := "../mesh.json"

	nm, err := navmesh.NewNavMesh(meshFileName)
	if err != nil {
		log.Fatal(err)
	}
	nmastar := navmesh.NewNavMeshAStar(nm)
	ps, isWalk := nmastar.FindPath(nmastar, 179, 41, 178, 886)
	log.Println(isWalk, ps)
	if isWalk {
		fn := "tt.cpuprof"
		f, err := os.Create(fn)
		if err != nil {
			log.Fatal(err)
		}
		err = pprof.StartCPUProfile(f)
		if err != nil {
			log.Fatal(err)
		}
		max := int64(100000)
		st := time.Now()
		for i := int64(0); i < max; i++ {
			nm.FindPath(nmastar, 179, 41, 178, 886)
		}
		nt := time.Since(st)
		log.Println(nt, nt.Nanoseconds()/max)

		pprof.StopCPUProfile()
	}
}
Example #2
0
File: main.go Project: gbember/gt
func main() {
	log.SetFlags(log.Lshortfile | log.Ldate)

	meshFileName := "../mesh.json"

	data, err := ioutil.ReadFile(meshFileName)
	if err != nil {
		log.Fatal(err)
	}
	nmj = new(navmesh.NavMeshJson)
	err = json.Unmarshal(data, nmj)
	if err != nil {
		log.Fatal(err)
	}

	n_m, err := navmesh.NewNavMesh(meshFileName)
	if err != nil {
		log.Fatal(err)
	}
	nm = n_m
	nmastar = navmesh.NewNavMeshAStar(nm)

	gl.StartDriver(appMain)

	//
	//	ps, isWalk := nm.FindPath(179, 41, 178, 886)
	//	log.Println(isWalk, ps)
	//	if isWalk {
	//		fn := "tt.cpuprof"
	//		f, err := os.Create(fn)
	//		if err != nil {
	//			log.Fatal(err)
	//		}
	//		err = pprof.StartCPUProfile(f)
	//		if err != nil {
	//			log.Fatal(err)
	//		}
	//		max := int64(100000)
	//		st := time.Now()
	//		for i := int64(0); i < max; i++ {
	//			nm.FindPath(179, 41, 178, 886)
	//		}
	//		nt := time.Since(st)
	//		log.Println(nt, nt.Nanoseconds()/max)

	//		pprof.StopCPUProfile()
	//	}
}