mirror of
https://github.com/golang/go
synced 2024-11-19 21:44:49 -07:00
18e86644a3
There may be further savings if convT2I can avoid the function call if the cache is good and T is uintptr-shaped, a la convT2E, but that will be a follow-up CL. src/pkg/runtime: benchmark old ns/op new ns/op delta BenchmarkConvT2ISmall 43 15 -64.01% BenchmarkConvT2IUintptr 45 14 -67.48% BenchmarkConvT2ILarge 130 101 -22.31% test/bench/go1: benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 8588997000 8499058000 -1.05% BenchmarkFannkuch11 5300392000 5358093000 +1.09% BenchmarkGobDecode 30295580 31040190 +2.46% BenchmarkGobEncode 18102070 17675650 -2.36% BenchmarkGzip 774191400 771591400 -0.34% BenchmarkGunzip 245915100 247464100 +0.63% BenchmarkJSONEncode 123577000 121423050 -1.74% BenchmarkJSONDecode 451969800 596256200 +31.92% BenchmarkMandelbrot200 10060050 10072880 +0.13% BenchmarkParse 10989840 11037710 +0.44% BenchmarkRevcomp 1782666000 1716864000 -3.69% BenchmarkTemplate 798286600 723234400 -9.40% R=rsc, bradfitz, go.peter.90, daniel.morsing, dave, uriel CC=golang-dev https://golang.org/cl/6337058
139 lines
1.9 KiB
Go
139 lines
1.9 KiB
Go
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime_test
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
type I1 interface {
|
|
Method1()
|
|
}
|
|
|
|
type I2 interface {
|
|
Method1()
|
|
Method2()
|
|
}
|
|
|
|
type TS uint16
|
|
type TM uintptr
|
|
type TL [2]uintptr
|
|
|
|
func (TS) Method1() {}
|
|
func (TS) Method2() {}
|
|
func (TM) Method1() {}
|
|
func (TM) Method2() {}
|
|
func (TL) Method1() {}
|
|
func (TL) Method2() {}
|
|
|
|
var (
|
|
e interface{}
|
|
e_ interface{}
|
|
i1 I1
|
|
i2 I2
|
|
ts TS
|
|
tm TM
|
|
tl TL
|
|
)
|
|
|
|
func BenchmarkConvT2ESmall(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
e = ts
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvT2EUintptr(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
e = tm
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvT2ELarge(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
e = tl
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvT2ISmall(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
i1 = ts
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvT2IUintptr(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
i1 = tm
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvT2ILarge(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
i1 = tl
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvI2E(b *testing.B) {
|
|
i2 = tm
|
|
for i := 0; i < b.N; i++ {
|
|
e = i2
|
|
}
|
|
}
|
|
|
|
func BenchmarkConvI2I(b *testing.B) {
|
|
i2 = tm
|
|
for i := 0; i < b.N; i++ {
|
|
i1 = i2
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertE2T(b *testing.B) {
|
|
e = tm
|
|
for i := 0; i < b.N; i++ {
|
|
tm = e.(TM)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertE2TLarge(b *testing.B) {
|
|
e = tl
|
|
for i := 0; i < b.N; i++ {
|
|
tl = e.(TL)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertE2I(b *testing.B) {
|
|
e = tm
|
|
for i := 0; i < b.N; i++ {
|
|
i1 = e.(I1)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertI2T(b *testing.B) {
|
|
i1 = tm
|
|
for i := 0; i < b.N; i++ {
|
|
tm = i1.(TM)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertI2I(b *testing.B) {
|
|
i1 = tm
|
|
for i := 0; i < b.N; i++ {
|
|
i2 = i1.(I2)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertI2E(b *testing.B) {
|
|
i1 = tm
|
|
for i := 0; i < b.N; i++ {
|
|
e = i1.(interface{})
|
|
}
|
|
}
|
|
|
|
func BenchmarkAssertE2E(b *testing.B) {
|
|
e = tm
|
|
for i := 0; i < b.N; i++ {
|
|
e_ = e
|
|
}
|
|
}
|