mirror of https://github.com/golang/go.git
all: Skip AllocsPerRun tests if GOMAXPROCS>1.
Fixes #4974. R=rsc, bradfitz, r CC=golang-dev https://golang.org/cl/7545043
This commit is contained in:
parent
45a3b3714f
commit
0a71a5b029
|
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -49,6 +50,10 @@ func BenchmarkEndToEndByteBuffer(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestCountEncodeMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
|
||||
const N = 1000
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
|
@ -65,6 +70,10 @@ func TestCountEncodeMallocs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCountDecodeMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
|
||||
const N = 1000
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
. "fmt"
|
||||
"io"
|
||||
"math"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -601,6 +602,9 @@ var mallocTest = []struct {
|
|||
var _ bytes.Buffer
|
||||
|
||||
func TestCountMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
for _, mt := range mallocTest {
|
||||
mallocs := testing.AllocsPerRun(100, mt.fn)
|
||||
if got, max := mallocs, float64(mt.count); got > max {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package http
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -192,6 +193,9 @@ func BenchmarkHeaderWriteSubset(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestHeaderWriteSubsetMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
n := testing.AllocsPerRun(100, func() {
|
||||
buf.Reset()
|
||||
testHeader.WriteSubset(&buf, nil)
|
||||
|
|
|
|||
|
|
@ -465,10 +465,16 @@ func countMallocs(dial func() (*Client, error), t *testing.T) float64 {
|
|||
}
|
||||
|
||||
func TestCountMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
fmt.Printf("mallocs per rpc round trip: %v\n", countMallocs(dialDirect, t))
|
||||
}
|
||||
|
||||
func TestCountMallocsOverHTTP(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
fmt.Printf("mallocs per HTTP rpc round trip: %v\n", countMallocs(dialHTTP, t))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,11 @@ func TestClean(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
|
||||
return
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
allocs := testing.AllocsPerRun(100, func() { filepath.Clean(test.result) })
|
||||
if allocs > 0 {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package path
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -72,6 +73,11 @@ func TestClean(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
|
||||
return
|
||||
}
|
||||
|
||||
for _, test := range cleantests {
|
||||
allocs := testing.AllocsPerRun(100, func() { Clean(test.result) })
|
||||
if allocs > 0 {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
. "reflect"
|
||||
"runtime"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -2011,6 +2012,9 @@ func TestAddr(t *testing.T) {
|
|||
}
|
||||
|
||||
func noAlloc(t *testing.T, n int, f func(int)) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
i := -1
|
||||
allocs := testing.AllocsPerRun(n, func() {
|
||||
f(i)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package sort_test
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
. "sort"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -127,6 +128,9 @@ func runSearchWrappers() {
|
|||
}
|
||||
|
||||
func TestSearchWrappersDontAlloc(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
allocs := testing.AllocsPerRun(100, runSearchWrappers)
|
||||
if allocs != 0 {
|
||||
t.Errorf("expected no allocs for runSearchWrappers, got %v", allocs)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package strconv_test
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
. "strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -43,6 +44,9 @@ var (
|
|||
)
|
||||
|
||||
func TestCountMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
for _, mt := range mallocTest {
|
||||
allocs := testing.AllocsPerRun(100, mt.fn)
|
||||
if max := float64(mt.count); allocs > max {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -1299,6 +1300,9 @@ var mallocTest = []struct {
|
|||
}
|
||||
|
||||
func TestCountMallocs(t *testing.T) {
|
||||
if runtime.GOMAXPROCS(0) > 1 {
|
||||
t.Skip("skipping; GOMAXPROCS>1")
|
||||
}
|
||||
for _, mt := range mallocTest {
|
||||
allocs := int(testing.AllocsPerRun(100, mt.fn))
|
||||
if allocs > mt.count {
|
||||
|
|
|
|||
Loading…
Reference in New Issue