...

Source file src/go.etcd.io/etcd/server/v3/mvcc/index_bench_test.go

Documentation: go.etcd.io/etcd/server/v3/mvcc

     1  // Copyright 2018 The etcd Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package mvcc
    16  
    17  import (
    18  	"testing"
    19  
    20  	"go.uber.org/zap"
    21  )
    22  
    23  func BenchmarkIndexCompact1(b *testing.B)       { benchmarkIndexCompact(b, 1) }
    24  func BenchmarkIndexCompact100(b *testing.B)     { benchmarkIndexCompact(b, 100) }
    25  func BenchmarkIndexCompact10000(b *testing.B)   { benchmarkIndexCompact(b, 10000) }
    26  func BenchmarkIndexCompact100000(b *testing.B)  { benchmarkIndexCompact(b, 100000) }
    27  func BenchmarkIndexCompact1000000(b *testing.B) { benchmarkIndexCompact(b, 1000000) }
    28  
    29  func benchmarkIndexCompact(b *testing.B, size int) {
    30  	log := zap.NewNop()
    31  	kvindex := newTreeIndex(log)
    32  
    33  	bytesN := 64
    34  	keys := createBytesSlice(bytesN, size)
    35  	for i := 1; i < size; i++ {
    36  		kvindex.Put(keys[i], revision{main: int64(i), sub: int64(i)})
    37  	}
    38  	b.ResetTimer()
    39  	for i := 1; i < b.N; i++ {
    40  		kvindex.Compact(int64(i))
    41  	}
    42  }
    43  

View as plain text