...

Source file src/go.etcd.io/etcd/server/v3/etcdserver/util_bench_test.go

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

     1  // Copyright 2021 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 etcdserver
    16  
    17  import (
    18  	"errors"
    19  	"go.etcd.io/etcd/raft/v3/raftpb"
    20  	"testing"
    21  	"time"
    22  )
    23  
    24  func BenchmarkWarnOfExpensiveRequestNoLog(b *testing.B) {
    25  	m := &raftpb.Message{
    26  		Type:    0,
    27  		To:      0,
    28  		From:    1,
    29  		Term:    2,
    30  		LogTerm: 3,
    31  		Index:   0,
    32  		Entries: []raftpb.Entry{
    33  			{
    34  				Term:  0,
    35  				Index: 0,
    36  				Type:  0,
    37  				Data:  make([]byte, 1024),
    38  			},
    39  		},
    40  		Commit:     0,
    41  		Snapshot:   raftpb.Snapshot{},
    42  		Reject:     false,
    43  		RejectHint: 0,
    44  		Context:    nil,
    45  	}
    46  	err := errors.New("benchmarking warn of expensive request")
    47  	for n := 0; n < b.N; n++ {
    48  		warnOfExpensiveRequest(testLogger, time.Second, time.Now(), nil, m, err)
    49  	}
    50  }
    51  

View as plain text