mirror of
https://github.com/golang/go
synced 2024-09-28 23:24:33 -06:00
fmt,math/big,net/url: fixes to old Benchmarks
b.ResetTimer used to also stop the timer, however it does not anymore. These benchmarks hadn't been fixed and as a result ended up measuring some additional things. Also, make some for loops more conventional. Change-Id: I76ca68456d85eec51722a80587e5b2c9f5d836a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/496996 Run-TryBot: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Auto-Submit: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
64c95d24f0
commit
74af79bcf6
@ -1096,10 +1096,10 @@ func testScanInts(t *testing.T, scan func(*RecursiveInt, *bytes.Buffer) error) {
|
||||
}
|
||||
|
||||
func BenchmarkScanInts(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.StopTimer()
|
||||
ints := makeInts(intCount)
|
||||
var r RecursiveInt
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := bytes.NewBuffer(ints)
|
||||
b.StartTimer()
|
||||
scanInts(&r, buf)
|
||||
@ -1108,10 +1108,10 @@ func BenchmarkScanInts(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkScanRecursiveInt(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.StopTimer()
|
||||
ints := makeInts(intCount)
|
||||
var r RecursiveInt
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := bytes.NewBuffer(ints)
|
||||
b.StartTimer()
|
||||
Fscan(buf, &r)
|
||||
@ -1120,10 +1120,10 @@ func BenchmarkScanRecursiveInt(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkScanRecursiveIntReaderWrapper(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.StopTimer()
|
||||
ints := makeInts(intCount)
|
||||
var r RecursiveInt
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := struct{ io.Reader }{strings.NewReader(string(ints))}
|
||||
b.StartTimer()
|
||||
Fscan(buf, &r)
|
||||
|
@ -254,7 +254,7 @@ func TestBinomial(t *testing.T) {
|
||||
|
||||
func BenchmarkBinomial(b *testing.B) {
|
||||
var z Int
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
for i := 0; i < b.N; i++ {
|
||||
z.Binomial(1000, 990)
|
||||
}
|
||||
}
|
||||
@ -1425,7 +1425,6 @@ func BenchmarkBitset(b *testing.B) {
|
||||
z := new(Int)
|
||||
z.SetBit(z, 512, 1)
|
||||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
z.SetBit(z, i&512, 1)
|
||||
}
|
||||
@ -1435,7 +1434,6 @@ func BenchmarkBitsetNeg(b *testing.B) {
|
||||
z := NewInt(-1)
|
||||
z.SetBit(z, 512, 0)
|
||||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
z.SetBit(z, i&512, 0)
|
||||
}
|
||||
@ -1445,7 +1443,6 @@ func BenchmarkBitsetOrig(b *testing.B) {
|
||||
z := new(Int)
|
||||
altSetBit(z, z, 512, 1)
|
||||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
altSetBit(z, z, i&512, 1)
|
||||
}
|
||||
@ -1455,7 +1452,6 @@ func BenchmarkBitsetNegOrig(b *testing.B) {
|
||||
z := NewInt(-1)
|
||||
altSetBit(z, z, 512, 0)
|
||||
b.ResetTimer()
|
||||
b.StartTimer()
|
||||
for i := b.N - 1; i >= 0; i-- {
|
||||
altSetBit(z, z, i&512, 0)
|
||||
}
|
||||
|
@ -1116,7 +1116,6 @@ func TestResolvePath(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkResolvePath(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
resolvePath("a/b/c", ".././d")
|
||||
|
Loading…
Reference in New Issue
Block a user