Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1509)

Delta Between Two Patch Sets: src/pkg/runtime/iface_test.go

Issue 5777048: code review 5777048: runtime: add interface microbenchmarks (Closed)
Left Patch Set: diff -r 3355c03e3e2c https://go.googlecode.com/hg/ Created 12 years ago
Right Patch Set: diff -r 29d6152320be https://go.googlecode.com/hg/ Created 11 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package runtime_test
6
7 import (
8 "bytes"
9 "io"
10 "testing"
11 )
12
13 var (
14 I interface{}
15 J int
16 B = new(bytes.Buffer)
17 W io.Writer = B
18 I2 interface{} = B
19 R io.ReadWriter = B
20 Big [2]*int
21 )
22
23 func BenchmarkConvT2E(b *testing.B) {
24 for i := 0; i < b.N; i++ {
25 I = 1
26 }
27 }
28
29 func BenchmarkConvT2EBig(b *testing.B) {
30 v := [2]*int{}
31 for i := 0; i < b.N; i++ {
32 I = v
33 }
34 }
35
36 func BenchmarkConvT2I(b *testing.B) {
37 for i := 0; i < b.N; i++ {
38 W = B
39 }
40 }
41
42 func BenchmarkConvI2E(b *testing.B) {
43 for i := 0; i < b.N; i++ {
44 I = W
45 }
46 }
47
48 func BenchmarkConvI2I(b *testing.B) {
49 for i := 0; i < b.N; i++ {
50 W = R
51 }
52 }
53
54 func BenchmarkAssertE2T(b *testing.B) {
55 I = 1
56 for i := 0; i < b.N; i++ {
57 J = I.(int)
58 }
59 }
60
61 func BenchmarkAssertE2TBig(b *testing.B) {
62 var v interface{} = [2]*int{}
63 for i := 0; i < b.N; i++ {
64 Big = v.([2]*int)
65 }
66 }
67
68 func BenchmarkAssertE2I(b *testing.B) {
69 for i := 0; i < b.N; i++ {
70 W = I2.(io.Writer)
71 }
72 }
73
74 func BenchmarkAssertI2T(b *testing.B) {
75 for i := 0; i < b.N; i++ {
76 B = W.(*bytes.Buffer)
77 }
78 }
79
80 func BenchmarkAssertI2I(b *testing.B) {
81 for i := 0; i < b.N; i++ {
82 W = R.(io.Writer)
83 }
84 }
85
86 func BenchmarkAssertI2E(b *testing.B) {
87 for i := 0; i < b.N; i++ {
88 I = R.(interface{})
89 }
90 }
91
92 func BenchmarkAssertE2E(b *testing.B) {
93 for i := 0; i < b.N; i++ {
94 I = I2.(interface{})
95 }
96 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b