mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 00:26:36 +03:00
lib: run go fix -rangeint
This commit is contained in:
@@ -20,7 +20,7 @@ func TestSlice_NoInit(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
for workerID := range workersCount {
|
||||
wg.Go(func() {
|
||||
for i := 0; i < loopsPerWorker; i++ {
|
||||
for i := range loopsPerWorker {
|
||||
bb := s.Get(uint(workerID))
|
||||
fmt.Fprintf(bb, "item %d at worker %d\n", i, workerID)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func TestSlice_NoInit(t *testing.T) {
|
||||
bbs = s.All()
|
||||
for workerID := range workersCount {
|
||||
var bbExpected bytes.Buffer
|
||||
for i := 0; i < loopsPerWorker; i++ {
|
||||
for i := range loopsPerWorker {
|
||||
fmt.Fprintf(&bbExpected, "item %d at worker %d\n", i, workerID)
|
||||
}
|
||||
bb := bbs[workerID]
|
||||
@@ -61,7 +61,7 @@ func TestSlice_Init(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
for workerID := range workersCount {
|
||||
wg.Go(func() {
|
||||
for i := 0; i < loopsPerWorker; i++ {
|
||||
for i := range loopsPerWorker {
|
||||
bb := s.Get(uint(workerID))
|
||||
fmt.Fprintf(bb, "item %d at worker %d\n", i, workerID)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestSlice_Init(t *testing.T) {
|
||||
bbs = s.All()
|
||||
for workerID := range workersCount {
|
||||
bbExpected := bytes.NewBufferString(prefix)
|
||||
for i := 0; i < loopsPerWorker; i++ {
|
||||
for i := range loopsPerWorker {
|
||||
fmt.Fprintf(bbExpected, "item %d at worker %d\n", i, workerID)
|
||||
}
|
||||
bb := bbs[workerID]
|
||||
|
||||
@@ -19,7 +19,7 @@ func BenchmarkSlice(b *testing.B) {
|
||||
workerID := uint(workerIDSource.Add(1) - 1)
|
||||
for pb.Next() {
|
||||
p := s.Get(workerID)
|
||||
for i := 0; i < loops; i++ {
|
||||
for i := range loops {
|
||||
*p += i
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func BenchmarkStandardSlice_Prealloc(b *testing.B) {
|
||||
workerID := uint(workerIDSource.Add(1) - 1)
|
||||
for pb.Next() {
|
||||
p := s[workerID]
|
||||
for i := 0; i < loops; i++ {
|
||||
for i := range loops {
|
||||
*p += i
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func BenchmarkStandardSlice_PerCPUAlloc(b *testing.B) {
|
||||
s[workerID] = new(int)
|
||||
for pb.Next() {
|
||||
p := s[workerID]
|
||||
for i := 0; i < loops; i++ {
|
||||
for i := range loops {
|
||||
*p += i
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func runParallelPerPathInternal(ctx context.Context, concurrency int, perPath ma
|
||||
|
||||
// Read results.
|
||||
var err error
|
||||
for i := 0; i < len(perPath); i++ {
|
||||
for range len(perPath) {
|
||||
err = <-resultCh
|
||||
if err != nil {
|
||||
// Stop the work.
|
||||
@@ -145,7 +145,7 @@ func runParallelInternal(concurrency int, parts []common.Part, f func(p common.P
|
||||
|
||||
// Read results.
|
||||
var err error
|
||||
for i := 0; i < len(parts); i++ {
|
||||
for range parts {
|
||||
err = <-resultCh
|
||||
if err != nil {
|
||||
// Stop the work.
|
||||
|
||||
@@ -83,7 +83,7 @@ func TestCache(t *testing.T) {
|
||||
if n := c.Misses(); n != 2 {
|
||||
t.Fatalf("unexpected number of misses; got %d; want %d", n, 2)
|
||||
}
|
||||
for i := 0; i < *missesBeforeCaching; i++ {
|
||||
for i := range *missesBeforeCaching {
|
||||
// Store the missed entry to the cache. It shouldn't be stored because of the previous cache miss
|
||||
c.TryPutBlock(k, &b)
|
||||
if n := c.SizeBytes(); n != 0 {
|
||||
@@ -142,7 +142,7 @@ func TestCacheConcurrentAccess(_ *testing.T) {
|
||||
}
|
||||
|
||||
func testCacheSetGet(c *Cache, worker int) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
part := (any)(i)
|
||||
b := testBlock{}
|
||||
k := Key{
|
||||
|
||||
@@ -29,7 +29,7 @@ func BenchmarkCacheGet(b *testing.B) {
|
||||
defer c.MustStop()
|
||||
const blocksCount = 10000
|
||||
blocks := make([]*testBlock, blocksCount)
|
||||
for i := 0; i < blocksCount; i++ {
|
||||
for i := range blocksCount {
|
||||
blocks[i] = &testBlock{}
|
||||
c.TryPutBlock(Key{Offset: uint64(i)}, blocks[i])
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func BenchmarkCacheGet(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
var k Key
|
||||
for pb.Next() {
|
||||
for i := 0; i < blocksCount; i++ {
|
||||
for i := range blocksCount {
|
||||
k.Offset = uint64(i)
|
||||
b := c.GetBlock(k)
|
||||
if b != blocks[i] {
|
||||
|
||||
@@ -42,7 +42,7 @@ func (f *filter) Has(h uint64) bool {
|
||||
maxBits := uint64(len(bits)) * 64
|
||||
bp := (*[8]byte)(unsafe.Pointer(&h))
|
||||
b := bp[:]
|
||||
for i := 0; i < hashesCount; i++ {
|
||||
for range hashesCount {
|
||||
hi := xxhash.Sum64(b)
|
||||
h++
|
||||
idx := hi % maxBits
|
||||
@@ -69,7 +69,7 @@ func (f *filter) Add(h uint64) bool {
|
||||
bp := (*[8]byte)(unsafe.Pointer(&h))
|
||||
b := bp[:]
|
||||
isNew := false
|
||||
for i := 0; i < hashesCount; i++ {
|
||||
for range hashesCount {
|
||||
hi := xxhash.Sum64(b)
|
||||
h++
|
||||
idx := hi % maxBits
|
||||
|
||||
@@ -20,7 +20,7 @@ func testFilter(t *testing.T, maxItems int) {
|
||||
|
||||
// Populate f with maxItems
|
||||
collisions := 0
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for i := range maxItems {
|
||||
h := r.Uint64()
|
||||
items[h] = struct{}{}
|
||||
if !f.Add(h) {
|
||||
@@ -64,7 +64,7 @@ func testFilter(t *testing.T, maxItems int) {
|
||||
|
||||
// Check filter reset
|
||||
f.Reset()
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for range maxItems {
|
||||
h := r.Uint64()
|
||||
if f.Has(h) {
|
||||
t.Fatalf("unexpected item found in empty filter: %d", h)
|
||||
@@ -77,10 +77,10 @@ func TestFilterConcurrent(t *testing.T) {
|
||||
maxItems := 10000
|
||||
doneCh := make(chan struct{}, concurrency)
|
||||
f := newFilter(maxItems)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := range concurrency {
|
||||
go func(randSeed int) {
|
||||
r := rand.New(rand.NewSource(int64(randSeed)))
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for range maxItems {
|
||||
h := r.Uint64()
|
||||
f.Add(h)
|
||||
if !f.Has(h) {
|
||||
@@ -91,7 +91,7 @@ func TestFilterConcurrent(t *testing.T) {
|
||||
}(i)
|
||||
}
|
||||
tC := time.After(time.Second * 5)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
select {
|
||||
case <-doneCh:
|
||||
case <-tC:
|
||||
|
||||
@@ -19,7 +19,7 @@ func benchmarkFilterAdd(b *testing.B, maxItems int) {
|
||||
f := newFilter(maxItems)
|
||||
for pb.Next() {
|
||||
h := uint64(0)
|
||||
for i := 0; i < 10000; i++ {
|
||||
for range 10000 {
|
||||
h += uint64(maxItems)
|
||||
f.Add(h)
|
||||
}
|
||||
@@ -41,13 +41,13 @@ func benchmarkFilterHasHit(b *testing.B, maxItems int) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
f := newFilter(maxItems)
|
||||
h := uint64(0)
|
||||
for i := 0; i < 10000; i++ {
|
||||
for range 10000 {
|
||||
h += uint64(maxItems)
|
||||
f.Add(h)
|
||||
}
|
||||
for pb.Next() {
|
||||
h = 0
|
||||
for i := 0; i < 10000; i++ {
|
||||
for range 10000 {
|
||||
h += uint64(maxItems)
|
||||
if !f.Has(h) {
|
||||
panic(fmt.Errorf("missing item %d", h))
|
||||
@@ -71,7 +71,7 @@ func benchmarkFilterHasMiss(b *testing.B, maxItems int) {
|
||||
f := newFilter(maxItems)
|
||||
for pb.Next() {
|
||||
h := uint64(0)
|
||||
for i := 0; i < 10000; i++ {
|
||||
for range 10000 {
|
||||
h += uint64(maxItems)
|
||||
if f.Has(h) {
|
||||
panic(fmt.Errorf("unexpected item %d", h))
|
||||
|
||||
@@ -22,7 +22,7 @@ func testLimiter(t *testing.T, maxItems int) {
|
||||
items := make(map[uint64]struct{}, maxItems)
|
||||
|
||||
// Populate the l with new items.
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for i := range maxItems {
|
||||
h := r.Uint64()
|
||||
if !l.Add(h) {
|
||||
t.Fatalf("cannot add item %d on iteration %d out of %d", h, i, maxItems)
|
||||
@@ -41,7 +41,7 @@ func testLimiter(t *testing.T, maxItems int) {
|
||||
|
||||
// Verify that new items are rejected with high probability.
|
||||
falseAdditions := 0
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for range maxItems {
|
||||
h := r.Uint64()
|
||||
if l.Add(h) {
|
||||
falseAdditions++
|
||||
@@ -58,13 +58,13 @@ func TestLimiterConcurrent(t *testing.T) {
|
||||
maxItems := 10000
|
||||
l := NewLimiter(maxItems, time.Hour)
|
||||
doneCh := make(chan struct{}, concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
go func() {
|
||||
if n := l.MaxItems(); n != maxItems {
|
||||
panic(fmt.Errorf("unexpected maxItems returned; got %d; want %d", n, maxItems))
|
||||
}
|
||||
r := rand.New(rand.NewSource(0))
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for range maxItems {
|
||||
h := r.Uint64()
|
||||
// Do not check whether the item is added, since less than maxItems can be added to l
|
||||
// due to passible (expected) race in l.f.Add
|
||||
@@ -72,7 +72,7 @@ func TestLimiterConcurrent(t *testing.T) {
|
||||
}
|
||||
// Verify that new items are rejected with high probability.
|
||||
falseAdditions := 0
|
||||
for i := 0; i < maxItems; i++ {
|
||||
for range maxItems {
|
||||
h := r.Uint64()
|
||||
if l.Add(h) {
|
||||
falseAdditions++
|
||||
@@ -86,7 +86,7 @@ func TestLimiterConcurrent(t *testing.T) {
|
||||
}()
|
||||
}
|
||||
tC := time.After(time.Second * 5)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
select {
|
||||
case <-doneCh:
|
||||
case <-tC:
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestRoundToNearestPow2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResizeNoCopyNoOverallocate(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
b := ResizeNoCopyNoOverallocate(nil, i)
|
||||
if len(b) != i {
|
||||
t.Fatalf("invalid b size; got %d; want %d", len(b), i)
|
||||
@@ -73,7 +73,7 @@ func TestResizeNoCopyNoOverallocate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResizeNoCopyMayOverallocate(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
b := ResizeNoCopyMayOverallocate(nil, i)
|
||||
if len(b) != i {
|
||||
t.Fatalf("invalid b size; got %d; want %d", len(b), i)
|
||||
@@ -110,7 +110,7 @@ func TestResizeNoCopyMayOverallocate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResizeWithCopyNoOverallocate(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
b := ResizeWithCopyNoOverallocate(nil, i)
|
||||
if len(b) != i {
|
||||
t.Fatalf("invalid b size; got %d; want %d", len(b), i)
|
||||
@@ -152,7 +152,7 @@ func TestResizeWithCopyNoOverallocate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResizeWithCopyMayOverallocate(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
b := ResizeWithCopyMayOverallocate(nil, i)
|
||||
if len(b) != i {
|
||||
t.Fatalf("invalid b size; got %d; want %d", len(b), i)
|
||||
|
||||
@@ -12,7 +12,7 @@ func TestFastStringMatcher(t *testing.T) {
|
||||
})
|
||||
f := func(s string, resultExpected bool) {
|
||||
t.Helper()
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
result := fsm.Match(s)
|
||||
if result != resultExpected {
|
||||
t.Fatalf("unexpected result for Match(%q) at iteration %d; got %v; want %v", s, i, result, resultExpected)
|
||||
|
||||
@@ -9,7 +9,7 @@ func TestFastStringTransformer(t *testing.T) {
|
||||
fst := NewFastStringTransformer(strings.ToUpper)
|
||||
f := func(s, resultExpected string) {
|
||||
t.Helper()
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
result := fst.Transform(s)
|
||||
if result != resultExpected {
|
||||
t.Fatalf("unexpected result for Transform(%q) at iteration %d; got %q; want %q", s, i, result, resultExpected)
|
||||
|
||||
@@ -15,13 +15,13 @@ func TestInternStringSerial(t *testing.T) {
|
||||
func TestInternStringConcurrent(t *testing.T) {
|
||||
concurrency := 5
|
||||
resultCh := make(chan error, concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
go func() {
|
||||
resultCh <- testInternString()
|
||||
}()
|
||||
}
|
||||
timer := time.NewTimer(5 * time.Second)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
select {
|
||||
case err := <-resultCh:
|
||||
if err != nil {
|
||||
@@ -34,7 +34,7 @@ func TestInternStringConcurrent(t *testing.T) {
|
||||
}
|
||||
|
||||
func testInternString() error {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
s := fmt.Sprintf("foo_%d", i)
|
||||
s1 := InternString(s)
|
||||
if s != s1 {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
func TestItoa(t *testing.T) {
|
||||
f := func(n int, resultExpected string) {
|
||||
t.Helper()
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
result := Itoa(n)
|
||||
if result != resultExpected {
|
||||
t.Fatalf("unexpected result for Itoa(%d); got %q; want %q", n, result, resultExpected)
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestBuffer(t *testing.T) {
|
||||
cb := Get()
|
||||
defer Put(cb)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
cb.Reset()
|
||||
|
||||
// Write data to chunked buffer
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestConsistentHash(t *testing.T) {
|
||||
rh := NewConsistentHash(nodes, 0)
|
||||
|
||||
keys := make([]uint64, 100000)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
for i := range keys {
|
||||
keys[i] = r.Uint64()
|
||||
}
|
||||
perIdxCounts := make([]int, len(nodes))
|
||||
|
||||
@@ -31,7 +31,7 @@ func BenchmarkConsistentHash(b *testing.B) {
|
||||
var benchKeys = func() []uint64 {
|
||||
r := rand.New(rand.NewSource(1))
|
||||
keys := make([]uint64, 10000)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
for i := range keys {
|
||||
keys[i] = r.Uint64()
|
||||
}
|
||||
return keys
|
||||
|
||||
@@ -507,7 +507,7 @@ func TestFloatToDecimalRoundtrip(t *testing.T) {
|
||||
f(vStaleNaN)
|
||||
|
||||
r := rand.New(rand.NewSource(1))
|
||||
for i := 0; i < 1e4; i++ {
|
||||
for range int(1e4) {
|
||||
v := r.NormFloat64()
|
||||
f(v)
|
||||
f(v * 1e-6)
|
||||
|
||||
@@ -59,7 +59,7 @@ func benchmarkAppendDecimalToFloat(b *testing.B, a []int64, scale int16) {
|
||||
var testZeros = make([]int64, 8*1024)
|
||||
var testOnes = func() []int64 {
|
||||
a := make([]int64, 8*1024)
|
||||
for i := 0; i < len(a); i++ {
|
||||
for i := range a {
|
||||
a[i] = 1
|
||||
}
|
||||
return a
|
||||
@@ -83,7 +83,7 @@ func BenchmarkAppendFloatToDecimal(b *testing.B) {
|
||||
var testFZeros = make([]float64, 8*1024)
|
||||
var testFOnes = func() []float64 {
|
||||
a := make([]float64, 8*1024)
|
||||
for i := 0; i < len(a); i++ {
|
||||
for i := range a {
|
||||
a[i] = 1
|
||||
}
|
||||
return a
|
||||
@@ -108,7 +108,7 @@ func benchmarkAppendFloatToDecimal(b *testing.B, fa []float64) {
|
||||
var testFAReal = func() []float64 {
|
||||
r := rand.New(rand.NewSource(1))
|
||||
fa := make([]float64, 8*1024)
|
||||
for i := 0; i < len(fa); i++ {
|
||||
for i := range fa {
|
||||
fa[i] = r.NormFloat64() * 1e-6
|
||||
}
|
||||
return fa
|
||||
@@ -117,7 +117,7 @@ var testFAReal = func() []float64 {
|
||||
var testFAInteger = func() []float64 {
|
||||
r := rand.New(rand.NewSource(2))
|
||||
fa := make([]float64, 8*1024)
|
||||
for i := 0; i < len(fa); i++ {
|
||||
for i := range fa {
|
||||
fa[i] = float64(int(r.NormFloat64() * 1e6))
|
||||
}
|
||||
return fa
|
||||
|
||||
@@ -53,7 +53,7 @@ func parseEnvVars(envs []string) map[string]string {
|
||||
}
|
||||
|
||||
func expandTemplates(m map[string]string) map[string]string {
|
||||
for i := 0; i < len(m); i++ {
|
||||
for range len(m) {
|
||||
mExpanded := make(map[string]string, len(m))
|
||||
expands := 0
|
||||
for name, value := range m {
|
||||
|
||||
@@ -134,7 +134,7 @@ func float64ToByteSlice(a []float64) []byte {
|
||||
var (
|
||||
int64Zeros [8 * 1024]int64
|
||||
int64Ones = func() (a [8 * 1024]int64) {
|
||||
for i := 0; i < len(a); i++ {
|
||||
for i := range len(a) {
|
||||
a[i] = 1
|
||||
}
|
||||
return a
|
||||
@@ -142,7 +142,7 @@ var (
|
||||
|
||||
float64Zeros [8 * 1024]float64
|
||||
float64Ones = func() (a [8 * 1024]float64) {
|
||||
for i := 0; i < len(a); i++ {
|
||||
for i := range len(a) {
|
||||
a[i] = 1
|
||||
}
|
||||
return a
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestIsInt64Ones(t *testing.T) {
|
||||
for _, n := range []int{0, 1, 10, 100, 1000, 1e4, 1e5, 8*1024 + 1} {
|
||||
t.Run(fmt.Sprintf("%d_items", n), func(t *testing.T) {
|
||||
a := make([]int64, n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
a[i] = 1
|
||||
}
|
||||
if !IsInt64Ones(a) {
|
||||
@@ -63,7 +63,7 @@ func TestIsFloat64Ones(t *testing.T) {
|
||||
for _, n := range []int{0, 1, 10, 100, 1000, 1e4, 1e5, 8*1024 + 1} {
|
||||
t.Run(fmt.Sprintf("%d_items", n), func(t *testing.T) {
|
||||
a := make([]float64, n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
a[i] = 1
|
||||
}
|
||||
if !IsFloat64Ones(a) {
|
||||
@@ -95,7 +95,7 @@ func TestAppendInt64Zeros(t *testing.T) {
|
||||
if len(a) != len(prefix)+n {
|
||||
t.Fatalf("unexpected len(a) with prefix; got %d; want %d", len(a), len(prefix)+n)
|
||||
}
|
||||
for i := 0; i < len(prefix); i++ {
|
||||
for i := range prefix {
|
||||
if a[i] != prefix[i] {
|
||||
t.Fatalf("unexpected prefix[%d]; got %d; want %d", i, a[i], prefix[i])
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func TestAppendInt64Ones(t *testing.T) {
|
||||
if len(a) != len(prefix)+n {
|
||||
t.Fatalf("unexpected len(a) with prefix; got %d; want %d", len(a), len(prefix)+n)
|
||||
}
|
||||
for i := 0; i < len(prefix); i++ {
|
||||
for i := range prefix {
|
||||
if a[i] != prefix[i] {
|
||||
t.Fatalf("unexpected prefix[%d]; got %d; want %d", i, a[i], prefix[i])
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func TestAppendFloat64Zeros(t *testing.T) {
|
||||
if len(a) != len(prefix)+n {
|
||||
t.Fatalf("unexpected len(a) with prefix; got %d; want %d", len(a), len(prefix)+n)
|
||||
}
|
||||
for i := 0; i < len(prefix); i++ {
|
||||
for i := range prefix {
|
||||
if a[i] != prefix[i] {
|
||||
t.Fatalf("unexpected prefix[%d]; got %f; want %f", i, a[i], prefix[i])
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func TestAppendFloat64Ones(t *testing.T) {
|
||||
if len(a) != len(prefix)+n {
|
||||
t.Fatalf("unexpected len(a) with prefix; got %d; want %d", len(a), len(prefix)+n)
|
||||
}
|
||||
for i := 0; i < len(prefix); i++ {
|
||||
for i := range prefix {
|
||||
if a[i] != prefix[i] {
|
||||
t.Fatalf("unexpected prefix[%d]; got %f; want %f", i, a[i], prefix[i])
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestPassword(t *testing.T) {
|
||||
if err := p.Set(expectedPassword); err != nil {
|
||||
t.Fatalf("cannot set password: %s", err)
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
if s := p.Get(); s != expectedPassword {
|
||||
t.Fatalf("unexpected password; got %q; want %q", s, expectedPassword)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func TestPassword(t *testing.T) {
|
||||
if err := p.Set(path); err != nil {
|
||||
t.Fatalf("cannot set password to file: %s", err)
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
if s := p.Get(); s != expectedPassword {
|
||||
t.Fatalf("unexpected password; got %q; want %q", s, expectedPassword)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func TestPassword(t *testing.T) {
|
||||
if err := p.Set(path); err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
if s := p.Get(); s != expectedPassword {
|
||||
t.Fatalf("unexpected password; got %q; want %q", s, expectedPassword)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func TestPassword(t *testing.T) {
|
||||
if err := p.Set("http://127.0.0.1:56283/aaa/bb?cc=dd"); err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
for range 5 {
|
||||
if s := p.Get(); len(s) != 64 {
|
||||
t.Fatalf("unexpected password obtained: %q; must be random 64-byte password", s)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ func (s *Server) serveTCP(insertHandler func(r io.Reader) error) {
|
||||
func (s *Server) serveUDP(insertHandler func(r io.Reader) error) {
|
||||
gomaxprocs := cgroup.AvailableCPUs()
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < gomaxprocs; i++ {
|
||||
for range gomaxprocs {
|
||||
wg.Go(func() {
|
||||
var bb bytesutil.ByteBuffer
|
||||
bb.B = bytesutil.ResizeNoCopyNoOverallocate(bb.B, 64*1024)
|
||||
|
||||
@@ -130,7 +130,7 @@ func (s *Server) serveTCP(insertHandler func(r io.Reader) error) {
|
||||
func (s *Server) serveUDP(insertHandler func(r io.Reader) error) {
|
||||
gomaxprocs := cgroup.AvailableCPUs()
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < gomaxprocs; i++ {
|
||||
for range gomaxprocs {
|
||||
wg.Go(func() {
|
||||
var bb bytesutil.ByteBuffer
|
||||
bb.B = bytesutil.ResizeNoCopyNoOverallocate(bb.B, 64*1024)
|
||||
|
||||
@@ -147,7 +147,7 @@ func (s *Server) serveTelnet(ln net.Listener, insertHandler func(r io.Reader) er
|
||||
func (s *Server) serveUDP(insertHandler func(r io.Reader) error) {
|
||||
gomaxprocs := cgroup.AvailableCPUs()
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < gomaxprocs; i++ {
|
||||
for range gomaxprocs {
|
||||
wg.Go(func() {
|
||||
var bb bytesutil.ByteBuffer
|
||||
bb.B = bytesutil.ResizeNoCopyNoOverallocate(bb.B, 64*1024)
|
||||
|
||||
@@ -22,7 +22,7 @@ var pools [10]sync.Pool
|
||||
// Get returns byte buffer, which is able to store at least dataLen bytes.
|
||||
func Get(dataLen int) *bytesutil.ByteBuffer {
|
||||
id, capacityNeeded := getPoolIDAndCapacity(dataLen)
|
||||
for i := 0; i < 2; i++ {
|
||||
for range 2 {
|
||||
if id < 0 || id >= len(pools) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func TestGetPutConcurrent(t *testing.T) {
|
||||
const concurrency = 10
|
||||
doneCh := make(chan struct{}, concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
go func() {
|
||||
for capacity := -1; capacity < 100; capacity++ {
|
||||
bb := Get(capacity)
|
||||
@@ -28,7 +28,7 @@ func TestGetPutConcurrent(t *testing.T) {
|
||||
}()
|
||||
}
|
||||
tc := time.After(10 * time.Second)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
select {
|
||||
case <-tc:
|
||||
t.Fatalf("timeout")
|
||||
|
||||
@@ -137,7 +137,7 @@ func TestCacheConcurrentAccess(_ *testing.T) {
|
||||
}
|
||||
|
||||
func testCacheSetGet(c *Cache, worker int) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := range 1000 {
|
||||
e := testEntry{}
|
||||
k := fmt.Sprintf("key_%d_%d", worker, i)
|
||||
c.PutEntry(k, &e)
|
||||
|
||||
@@ -98,7 +98,7 @@ func (sc *statDialConn) Close() error {
|
||||
|
||||
func isTCPv4Addr(addr string) bool {
|
||||
s := addr
|
||||
for i := 0; i < 3; i++ {
|
||||
for range 3 {
|
||||
n := strings.IndexByte(s, '.')
|
||||
if n < 0 {
|
||||
return false
|
||||
|
||||
@@ -33,7 +33,7 @@ func BenchmarkWriteRequestMarshalProtobuf(b *testing.B) {
|
||||
|
||||
var benchWriteRequest = func() *WriteRequest {
|
||||
var tss []TimeSeries
|
||||
for i := 0; i < 1_000; i++ {
|
||||
for i := range 1_000 {
|
||||
ts := TimeSeries{
|
||||
Labels: []Label{
|
||||
{
|
||||
|
||||
@@ -86,7 +86,9 @@ func (gmt *graphiteMatchTemplate) Match(dst []string, s string) ([]string, bool)
|
||||
return dst, false
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(parts); i++ {
|
||||
|
||||
i := 0
|
||||
for i < len(parts) {
|
||||
p := parts[i]
|
||||
if p != "*" {
|
||||
if !strings.HasPrefix(s, p) {
|
||||
@@ -94,6 +96,7 @@ func (gmt *graphiteMatchTemplate) Match(dst []string, s string) ([]string, bool)
|
||||
return dst, false
|
||||
}
|
||||
s = s[len(p):]
|
||||
i++
|
||||
continue
|
||||
}
|
||||
// Search for the matching substring for '*' part.
|
||||
@@ -108,7 +111,7 @@ func (gmt *graphiteMatchTemplate) Match(dst []string, s string) ([]string, bool)
|
||||
}
|
||||
// Search for the start of the next part.
|
||||
p = parts[i+1]
|
||||
i++
|
||||
i += 2
|
||||
n := strings.Index(s, p)
|
||||
if n < 0 {
|
||||
// Cannot match the next part
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func BenchmarkIfExpression(b *testing.B) {
|
||||
const maxLabels = 100
|
||||
labels := make([]prompb.Label, maxLabels)
|
||||
for i := 0; i < maxLabels; i++ {
|
||||
for i := range maxLabels {
|
||||
label := prompb.Label{
|
||||
Name: fmt.Sprintf("foo%d", i),
|
||||
Value: fmt.Sprintf("bar%d", i),
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestSanitizeMetricName(t *testing.T) {
|
||||
f := func(s, resultExpected string) {
|
||||
t.Helper()
|
||||
for i := 0; i < 5; i++ {
|
||||
for i := range 5 {
|
||||
result := SanitizeMetricName(s)
|
||||
if result != resultExpected {
|
||||
t.Fatalf("unexpected result for SanitizeMetricName(%q) at iteration %d; got %q; want %q", s, i, result, resultExpected)
|
||||
@@ -28,7 +28,7 @@ func TestSanitizeMetricName(t *testing.T) {
|
||||
func TestSanitizeLabelName(t *testing.T) {
|
||||
f := func(s, resultExpected string) {
|
||||
t.Helper()
|
||||
for i := 0; i < 5; i++ {
|
||||
for i := range 5 {
|
||||
result := SanitizeLabelName(s)
|
||||
if result != resultExpected {
|
||||
t.Fatalf("unexpected result for SanitizeLabelName(%q) at iteration %d; got %q; want %q", s, i, result, resultExpected)
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestLabelsCompressorConcurrent(t *testing.T) {
|
||||
var expectCompressedKeys sync.Map
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := range concurrency {
|
||||
wg.Go(func() {
|
||||
series := newTestSeries(100, 20)
|
||||
for n, labels := range series {
|
||||
@@ -109,9 +109,9 @@ func labelsToString(labels []prompb.Label) string {
|
||||
|
||||
func newTestSeries(seriesCount, labelsPerSeries int) [][]prompb.Label {
|
||||
series := make([][]prompb.Label, seriesCount)
|
||||
for i := 0; i < seriesCount; i++ {
|
||||
for i := range seriesCount {
|
||||
labels := make([]prompb.Label, labelsPerSeries)
|
||||
for j := 0; j < labelsPerSeries; j++ {
|
||||
for j := range labelsPerSeries {
|
||||
labels[j] = prompb.Label{
|
||||
Name: fmt.Sprintf("label_%d", j),
|
||||
Value: fmt.Sprintf("value_%d_%d", i, j),
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestParseStream(t *testing.T) {
|
||||
return fmt.Errorf("unexpected time series count; got: %d; want: %d\ntimeseries got:\n%s\ntimeseries want\n%s",
|
||||
len(tss), len(tssExpected), prettifyTimeSeries(tss), prettifyTimeSeries(tssExpected))
|
||||
}
|
||||
for i := 0; i < len(tss); i++ {
|
||||
for i := range tss {
|
||||
ts := tss[i]
|
||||
tsExpected := tssExpected[i]
|
||||
if len(ts.Labels) != len(tsExpected.Labels) {
|
||||
|
||||
@@ -103,9 +103,9 @@ func BenchmarkWriteRequestContextPushSample(b *testing.B) {
|
||||
timeSeriesCount := 100000
|
||||
labels := make([]*promutil.Labels, 0, timeSeriesCount)
|
||||
mms := make([]*pb.MetricMetadata, 0, timeSeriesCount)
|
||||
for i := 0; i < timeSeriesCount; i++ {
|
||||
for i := range timeSeriesCount {
|
||||
lbs := &promutil.Labels{}
|
||||
for j := 0; j < 20; j++ {
|
||||
for j := range 20 {
|
||||
lbs.Labels = append(lbs.Labels, prompb.Label{
|
||||
Name: fmt.Sprintf("some_super_long_label_%d", j),
|
||||
Value: fmt.Sprintf("some_super_super_super_super_super_super_long_label_%d", j),
|
||||
@@ -129,7 +129,7 @@ func BenchmarkWriteRequestContextPushSample(b *testing.B) {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < timeSeriesCount; i++ {
|
||||
for i := range timeSeriesCount {
|
||||
benchmarkWriteRequestContextPushSample(b, wctx, mms[i], labels[i])
|
||||
}
|
||||
|
||||
|
||||
@@ -747,7 +747,7 @@ func AreIdenticalSeriesFast(s1, s2 string) bool {
|
||||
}
|
||||
|
||||
func isNumeric(s string) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
for i := range len(s) {
|
||||
if numericChars[s[i]] {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ type span struct {
|
||||
|
||||
func (s *span) writePlaintextWithIndent(w io.Writer, indent int) {
|
||||
prefix := ""
|
||||
for i := 0; i < indent; i++ {
|
||||
for range indent {
|
||||
prefix += "| "
|
||||
}
|
||||
prefix += "- "
|
||||
|
||||
@@ -151,10 +151,10 @@ func TestTraceConcurrent(t *testing.T) {
|
||||
childLocal.Printf("abc")
|
||||
childLocal.Done()
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := range 3 {
|
||||
child := qt.NewChild("child %d", i)
|
||||
wg.Go(func() {
|
||||
for j := 0; j < 100; j++ {
|
||||
for j := range 100 {
|
||||
child.Printf("message %d", j)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ func AppendLowercase(dst []byte, s string) []byte {
|
||||
|
||||
// Try fast path at first by assuming that s contains only ASCII chars.
|
||||
hasUnicodeChars := false
|
||||
for i := 0; i < len(s); i++ {
|
||||
for i := range len(s) {
|
||||
c := s[i]
|
||||
if c >= utf8.RuneSelf {
|
||||
hasUnicodeChars = true
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestCounterMap(t *testing.T) {
|
||||
func TestCounterMapConcurrent(t *testing.T) {
|
||||
cm := NewCounterMap(`aaa{bb="cc"}`)
|
||||
f := func() error {
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
cm.Get(&auth.Token{AccountID: 1, ProjectID: 2}).Inc()
|
||||
if n := cm.Get(&auth.Token{AccountID: 3, ProjectID: 4}).Get(); n != 0 {
|
||||
return fmt.Errorf("unexpected counter value; got %d; want %d", n, 0)
|
||||
@@ -64,13 +64,13 @@ func TestCounterMapConcurrent(t *testing.T) {
|
||||
|
||||
const concurrency = 5
|
||||
ch := make(chan error, concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
go func() {
|
||||
ch <- f()
|
||||
}()
|
||||
}
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for range concurrency {
|
||||
select {
|
||||
case err := <-ch:
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ func BenchmarkCounterMapGrowth(b *testing.B) {
|
||||
f := func(b *testing.B, numTenants uint32, nProcs int) {
|
||||
b.Helper()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range b.N {
|
||||
cm := NewCounterMap("foobar")
|
||||
var wg sync.WaitGroup
|
||||
for range nProcs {
|
||||
|
||||
@@ -162,7 +162,7 @@ func TestSetOps(t *testing.T) {
|
||||
f([]uint64{0, 2 << 32}, []uint64{1 << 32, 2 << 32, 3 << 32})
|
||||
|
||||
var a []uint64
|
||||
for i := 0; i < 100; i++ {
|
||||
for i := range 100 {
|
||||
a = append(a, uint64(i))
|
||||
}
|
||||
var b []uint64
|
||||
@@ -180,10 +180,10 @@ func TestSetOps(t *testing.T) {
|
||||
f(a, b)
|
||||
|
||||
r := rand.New(rand.NewSource(1))
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
a = nil
|
||||
b = nil
|
||||
for j := 0; j < 1000; j++ {
|
||||
for range 1000 {
|
||||
a = append(a, uint64(r.Intn(1e6)))
|
||||
b = append(b, uint64(r.Intn(1e6)))
|
||||
}
|
||||
@@ -283,7 +283,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
|
||||
// Verify forward Add
|
||||
itemsCount = (itemsCount / 2) * 2
|
||||
for i := 0; i < itemsCount/2; i++ {
|
||||
for i := range itemsCount / 2 {
|
||||
s.Add(uint64(i) + offset)
|
||||
}
|
||||
if n := s.Len(); n != itemsCount/2 {
|
||||
@@ -294,7 +294,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
}
|
||||
|
||||
// Verify backward Add
|
||||
for i := 0; i < itemsCount/2; i++ {
|
||||
for i := range itemsCount / 2 {
|
||||
s.Add(uint64(itemsCount-i-1) + offset)
|
||||
}
|
||||
if n := s.Len(); n != itemsCount {
|
||||
@@ -302,7 +302,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
}
|
||||
|
||||
// Verify repeated Add
|
||||
for i := 0; i < itemsCount/2; i++ {
|
||||
for i := range itemsCount / 2 {
|
||||
s.Add(uint64(i) + offset)
|
||||
}
|
||||
if n := s.Len(); n != itemsCount {
|
||||
@@ -310,7 +310,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
}
|
||||
|
||||
// Verify Has on existing bits
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
if !s.Has(uint64(i) + offset) {
|
||||
t.Fatalf("missing bit %d", uint64(i)+offset)
|
||||
}
|
||||
@@ -328,7 +328,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
if n := sCopy.Len(); n != itemsCount {
|
||||
t.Fatalf("unexpected sCopy.Len(); got %d; want %d", n, itemsCount)
|
||||
}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
if !sCopy.Has(uint64(i) + offset) {
|
||||
t.Fatalf("missing bit %d on sCopy", uint64(i)+offset)
|
||||
}
|
||||
@@ -373,7 +373,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
for _, x := range a {
|
||||
m[x] = true
|
||||
}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
if !m[uint64(i)+offset] {
|
||||
t.Fatalf("missing bit %d in the exported bits; array:\n%d", uint64(i)+offset, a)
|
||||
}
|
||||
@@ -383,7 +383,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
{
|
||||
var s Set
|
||||
m := make(map[uint64]bool)
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
v := uint64(i) + offset
|
||||
s.Add(v)
|
||||
m[v] = true
|
||||
@@ -425,7 +425,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
{
|
||||
const unionOffset = 12345
|
||||
var s1, s2 Set
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
s1.Add(uint64(i) + offset)
|
||||
s2.Add(uint64(i) + offset + unionOffset)
|
||||
}
|
||||
@@ -457,7 +457,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
{
|
||||
const unionOffset = 12345
|
||||
var s1, s2 Set
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
s1.Add(uint64(i) + offset)
|
||||
s2.Add(uint64(i) + offset + unionOffset)
|
||||
}
|
||||
@@ -492,7 +492,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
for _, intersectOffset := range []uint64{123, 12345, 1<<32 + 4343} {
|
||||
s1 = Set{}
|
||||
s2 = Set{}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
s1.Add(uint64(i) + offset)
|
||||
s2.Add(uint64(i) + offset + intersectOffset)
|
||||
}
|
||||
@@ -529,7 +529,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
{
|
||||
const subtractOffset = 12345
|
||||
var s1, s2 Set
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
s1.Add(uint64(i) + offset)
|
||||
s2.Add(uint64(i) + offset + subtractOffset)
|
||||
}
|
||||
@@ -568,7 +568,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
for _, x := range a {
|
||||
m[x] = true
|
||||
}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
if i >= itemsCount/2 && i < itemsCount-itemsCount/4 {
|
||||
if m[uint64(i)+offset] {
|
||||
t.Fatalf("unexpected bit found after deleting: %d", uint64(i)+offset)
|
||||
@@ -594,7 +594,7 @@ func testSetBasicOps(t *testing.T, itemsCount int) {
|
||||
if n := sCopy.Len(); n != itemsCount {
|
||||
t.Fatalf("unexpected sCopy.Len(); got %d; want %d", n, itemsCount)
|
||||
}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
if !sCopy.Has(uint64(i) + offset) {
|
||||
t.Fatalf("missing bit %d on sCopy", uint64(i)+offset)
|
||||
}
|
||||
@@ -613,7 +613,7 @@ func testSetSparseItems(t *testing.T, itemsCount int) {
|
||||
r := rand.New(rand.NewSource(1))
|
||||
var s Set
|
||||
m := make(map[uint64]bool)
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for range itemsCount {
|
||||
x := r.Uint64()
|
||||
s.Add(x)
|
||||
m[x] = true
|
||||
@@ -631,7 +631,7 @@ func testSetSparseItems(t *testing.T, itemsCount int) {
|
||||
t.Fatalf("missing item %d", x)
|
||||
}
|
||||
}
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
x := uint64(i)
|
||||
if m[x] {
|
||||
continue
|
||||
@@ -743,19 +743,19 @@ func TestAddMulti(t *testing.T) {
|
||||
f([]uint64{0, 1 << 16, 2 << 16, 2<<16 + 1, 1 << 32, 2 << 32, 2<<32 + 1})
|
||||
|
||||
var a []uint64
|
||||
for i := 0; i < 32000; i++ {
|
||||
for i := range 32000 {
|
||||
a = append(a, uint64(i))
|
||||
}
|
||||
f(a)
|
||||
|
||||
a = nil
|
||||
for i := 0; i < 32000; i++ {
|
||||
for i := range 32000 {
|
||||
a = append(a, 1<<16+uint64(i))
|
||||
}
|
||||
f(a)
|
||||
|
||||
a = nil
|
||||
for i := 0; i < 100000; i++ {
|
||||
for i := range 100000 {
|
||||
a = append(a, 1<<32+uint64(i))
|
||||
}
|
||||
f(a)
|
||||
|
||||
@@ -216,7 +216,7 @@ func BenchmarkSubtract(b *testing.B) {
|
||||
|
||||
func createRangeSet(start uint64, itemsCount int) *Set {
|
||||
var s Set
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for i := range itemsCount {
|
||||
n := start + uint64(i)
|
||||
s.Add(n)
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func BenchmarkSetAddRandomLastBits(b *testing.B) {
|
||||
for pb.Next() {
|
||||
start := uint64(time.Now().UnixNano())
|
||||
var s Set
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for range int(itemsCount) {
|
||||
n := start | (uint64(rng.Uint32()) & mask)
|
||||
s.Add(n)
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func BenchmarkMapAddRandomLastBits(b *testing.B) {
|
||||
for pb.Next() {
|
||||
start := uint64(time.Now().UnixNano())
|
||||
m := make(map[uint64]struct{})
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for range int(itemsCount) {
|
||||
n := start | (uint64(rng.Uint32()) & mask)
|
||||
m[n] = struct{}{}
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func BenchmarkSetHasHitRandomLastBits(b *testing.B) {
|
||||
start := uint64(time.Now().UnixNano())
|
||||
var s Set
|
||||
var rng fastrand.RNG
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for range int(itemsCount) {
|
||||
n := start | (uint64(rng.Uint32()) & mask)
|
||||
s.Add(n)
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func BenchmarkMapHasHitRandomLastBits(b *testing.B) {
|
||||
start := uint64(time.Now().UnixNano())
|
||||
m := make(map[uint64]struct{})
|
||||
var rng fastrand.RNG
|
||||
for i := 0; i < itemsCount; i++ {
|
||||
for range int(itemsCount) {
|
||||
n := start | (uint64(rng.Uint32()) & mask)
|
||||
m[n] = struct{}{}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ func testSetBigGetBigStatsInSplitMode(t *testing.T, c *Cache) {
|
||||
|
||||
v := func(seed, size int) []byte {
|
||||
var buf []byte
|
||||
for i := 0; i < size; i++ {
|
||||
for i := range size {
|
||||
buf = append(buf, byte(i+seed))
|
||||
}
|
||||
return buf
|
||||
@@ -530,7 +530,7 @@ func TestSetBigGetBigStatsInWholeMode_cacheLoadedFromNonEmptyFile(t *testing.T)
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
v := func(seed, size int) []byte {
|
||||
var buf []byte
|
||||
for i := 0; i < size; i++ {
|
||||
for i := range size {
|
||||
buf = append(buf, byte(i+seed))
|
||||
}
|
||||
return buf
|
||||
|
||||
Reference in New Issue
Block a user