github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/test/fixedbugs/issue16008.go (about) 1 // errorcheck -0 -race 2 // +build linux,amd64 linux,ppc64le darwin,amd64 freebsd,amd64 netbsd,amd64 windows,amd64 3 4 // Copyright 2016 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package foo 9 10 const benchmarkNumNodes = 10000 11 12 func BenchmarkUpdateNodeTransaction(b B) { 13 s, nodeIDs := setupNodes(benchmarkNumNodes) 14 b.ResetTimer() 15 for i := 0; i < b.N(); i++ { 16 _ = s.Update(func(tx1 Tx) error { 17 _ = UpdateNode(tx1, &Node{ 18 ID: nodeIDs[i%benchmarkNumNodes], 19 }) 20 return nil 21 }) 22 } 23 } 24 25 type B interface { 26 ResetTimer() 27 N() int 28 } 29 30 type Tx interface { 31 } 32 33 type Node struct { 34 ID string 35 } 36 37 type MemoryStore struct { 38 } 39 40 // go:noinline 41 func setupNodes(n int) (s *MemoryStore, nodeIDs []string) { 42 return 43 } 44 45 //go:noinline 46 func (s *MemoryStore) Update(cb func(Tx) error) error { 47 return nil 48 } 49 50 var sink interface{} 51 52 //go:noinline 53 func UpdateNode(tx Tx, n *Node) error { 54 sink = tx 55 sink = n 56 return nil 57 }