1 // Copyright 2011 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.
10 func BenchmarkCallClosure(b
*testing
.B
) {
11 for i
:= 0; i
< b
.N
; i
++ {
12 s
+= func(ii
int) int { return 2 * ii
}(i
)
16 func BenchmarkCallClosure1(b
*testing
.B
) {
17 for i
:= 0; i
< b
.N
; i
++ {
19 s
+= func(ii
int) int { return 2*ii
+ j
}(i
)
25 func BenchmarkCallClosure2(b
*testing
.B
) {
26 for i
:= 0; i
< b
.N
; i
++ {
35 func addr1(x
int) *int {
36 return func() *int { return &x
}()
39 func BenchmarkCallClosure3(b
*testing
.B
) {
40 for i
:= 0; i
< b
.N
; i
++ {
45 func addr2() (x
int, p
*int) {
46 return 0, func() *int { return &x
}()
49 func BenchmarkCallClosure4(b
*testing
.B
) {
50 for i
:= 0; i
< b
.N
; i
++ {