mirror of
https://github.com/golang/go
synced 2024-11-17 17:34:46 -07:00
b2fd76ab8d
Most of the test cases in the test directory use the new go:build syntax already. Convert the rest. In general, try to place the build constraint line below the test directive comment in more places. For #41184. For #60268. Change-Id: I11c41a0642a8a26dc2eda1406da908645bbc005b Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/536236 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
// errorcheck -0 -race
|
|
|
|
//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64)
|
|
|
|
// Copyright 2016 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 foo
|
|
|
|
const benchmarkNumNodes = 10000
|
|
|
|
func BenchmarkUpdateNodeTransaction(b B) {
|
|
s, nodeIDs := setupNodes(benchmarkNumNodes)
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N(); i++ {
|
|
_ = s.Update(func(tx1 Tx) error {
|
|
_ = UpdateNode(tx1, &Node{
|
|
ID: nodeIDs[i%benchmarkNumNodes],
|
|
})
|
|
return nil
|
|
})
|
|
}
|
|
}
|
|
|
|
type B interface {
|
|
ResetTimer()
|
|
N() int
|
|
}
|
|
|
|
type Tx interface {
|
|
}
|
|
|
|
type Node struct {
|
|
ID string
|
|
}
|
|
|
|
type MemoryStore struct {
|
|
}
|
|
|
|
//go:noinline
|
|
func setupNodes(n int) (s *MemoryStore, nodeIDs []string) {
|
|
return
|
|
}
|
|
|
|
//go:noinline
|
|
func (s *MemoryStore) Update(cb func(Tx) error) error {
|
|
return nil
|
|
}
|
|
|
|
var sink interface{}
|
|
|
|
//go:noinline
|
|
func UpdateNode(tx Tx, n *Node) error {
|
|
sink = tx
|
|
sink = n
|
|
return nil
|
|
}
|