@@ -121,7 +121,7 @@ func TestBroadPhaseTwoStaticBodies(t *testing.T) {
121121 }
122122
123123 // Static-static collisions should be skipped
124- if len (pairs ) != 0 {
124+ if len (contactPairs ) != 0 {
125125 t .Errorf ("BroadPhase with two static bodies returned %d pairs, want 0 (should skip static-static)" , len (pairs ))
126126 }
127127}
@@ -563,9 +563,7 @@ func BenchmarkLargeBroadPhase2(b *testing.B) {
563563}
564564
565565// BenchmarkLargeGJK2-16 1010 1174808 ns/op 133546 B/op 2362 allocs/op
566- // BenchmarkLargeGJK2-16 100 10239257 ns/op 1073609 B/op 24118 allocs/op
567- // BenchmarkLargeGJK2-16 100 19060863 ns/op 1000860 B/op 10399 allocs/op
568- // BenchmarkLargeGJK2-16 126 9732729 ns/op 1172060 B/op 10395 allocs/op
566+ // BenchmarkLargeGJK2-16 32847 40166 ns/op 16228 B/op 53 allocs/op
569567func BenchmarkLargeGJK2 (b * testing.B ) {
570568 const cubesCount = 1000
571569 const rowSize = 100.0
@@ -587,12 +585,14 @@ func BenchmarkLargeGJK2(b *testing.B) {
587585 f , _ := os .Create ("trace.out" )
588586 fcpu , _ := os .Create (`cpu.prof` )
589587 fheap , _ := os .Create (`heap.prof` )
590- defer f .Close ()
591- defer fcpu .Close ()
592- defer fheap .Close ()
593- pprof .StartCPUProfile (fcpu )
594- pprof .WriteHeapProfile (fheap )
595- trace .Start (f )
588+ defer func () {
589+ _ = f .Close ()
590+ _ = fcpu .Close ()
591+ _ = fheap .Close ()
592+ }()
593+ _ = pprof .StartCPUProfile (fcpu )
594+ _ = pprof .WriteHeapProfile (fheap )
595+ _ = trace .Start (f )
596596
597597 b .ReportAllocs ()
598598 b .ResetTimer ()
@@ -602,11 +602,8 @@ func BenchmarkLargeGJK2(b *testing.B) {
602602 b .StartTimer ()
603603
604604 collisionPair := GJK (pair )
605-
606- for cp := range collisionPair {
607- s := cp .simplex .Count
608- s ++
609- }
605+ cp := <- collisionPair
606+ cp .BodyA .IsSleeping = false
610607 }
611608
612609 b .StopTimer ()
@@ -643,12 +640,14 @@ func BenchmarkLargeEPA2(b *testing.B) {
643640 f , _ := os .Create ("trace.out" )
644641 fcpu , _ := os .Create (`cpu.prof` )
645642 fheap , _ := os .Create (`heap.prof` )
646- defer f .Close ()
647- defer fcpu .Close ()
648- defer fheap .Close ()
649- pprof .StartCPUProfile (fcpu )
650- pprof .WriteHeapProfile (fheap )
651- trace .Start (f )
643+ defer func () {
644+ _ = f .Close ()
645+ _ = fcpu .Close ()
646+ _ = fheap .Close ()
647+ }()
648+ _ = pprof .StartCPUProfile (fcpu )
649+ _ = pprof .WriteHeapProfile (fheap )
650+ _ = trace .Start (f )
652651
653652 b .ReportAllocs ()
654653 b .ResetTimer ()
@@ -756,12 +755,14 @@ func BenchmarkLargeWorldStep(b *testing.B) {
756755 f , _ := os .Create ("trace.out" )
757756 fcpu , _ := os .Create (`cpu.prof` )
758757 fheap , _ := os .Create (`heap.prof` )
759- defer f .Close ()
760- defer fcpu .Close ()
761- defer fheap .Close ()
762- pprof .StartCPUProfile (fcpu )
763- pprof .WriteHeapProfile (fheap )
764- trace .Start (f )
758+ defer func () {
759+ _ = f .Close ()
760+ _ = fcpu .Close ()
761+ _ = fheap .Close ()
762+ }()
763+ _ = pprof .StartCPUProfile (fcpu )
764+ _ = pprof .WriteHeapProfile (fheap )
765+ _ = trace .Start (f )
765766
766767 b .ReportAllocs ()
767768 b .ResetTimer ()
0 commit comments