This commit is contained in:
knight0zh
2022-08-16 16:53:26 +08:00
parent 41f16ef6e9
commit 59e6f5d6c1
4 changed files with 10 additions and 8 deletions

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
bench:
go test -bench=. -benchmem -count=3

View File

@@ -128,13 +128,13 @@ func TestNewGridManger(t *testing.T) {
func BenchmarkGridManger(b *testing.B) {
var wg sync.WaitGroup
aol := NewGridManger(0, 0, 250, 5)
aol := NewGridManger(0, 0, 256, 16)
manger := aol.(*GridManger)
rand.Seed(time.Now().UnixNano())
for i := 0; i < b.N; i++ {
wg.Add(3000)
for j := 0; j < 1000; j++ {
wg.Add(30000)
for j := 0; j < 10000; j++ {
go func() {
manger.Add(&Entity{
X: float64(rand.Intn(5) * 10),

View File

@@ -9,8 +9,8 @@ const (
rightDown
maxCap = 500 // 节点最大容量
maxDeep = 5 // 节点最大深度
radius = 20 // 视野半径
maxDeep = 3 // 节点最大深度
radius = 16 // 视野半径
)
type QuadOption func(*QuadTree)

View File

@@ -152,8 +152,8 @@ func BenchmarkQuadtree(b *testing.B) {
rand.Seed(time.Now().UnixNano())
for i := 0; i < b.N; i++ {
wg.Add(3000)
for j := 0; j < 1000; j++ {
wg.Add(30000)
for j := 0; j < 10000; j++ {
go func() {
tree.Add(&Entity{
X: float64(rand.Intn(5) * 10),
@@ -181,4 +181,4 @@ func BenchmarkQuadtree(b *testing.B) {
}()
}
}
}
}