1 // Copyright 2021 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 token 6 7 import ( 8 "testing" 9 ) 10 11 func BenchmarkSearchInts(b *testing.B) { 12 data := make([]int, 10000) 13 for i := 0; i < 10000; i++ { 14 data[i] = i 15 } 16 const x = 8 17 if r := searchInts(data, x); r != x { 18 b.Errorf("got index = %d; want %d", r, x) 19 } 20 b.ResetTimer() 21 for i := 0; i < b.N; i++ { 22 searchInts(data, x) 23 } 24 } 25