...

Source file src/github.com/gin-gonic/gin/binding/default_validator_benchmark_test.go

Documentation: github.com/gin-gonic/gin/binding

     1  // Copyright 2022 Gin Core Team. All rights reserved.
     2  // Use of this source code is governed by a MIT style
     3  // license that can be found in the LICENSE file.
     4  
     5  package binding
     6  
     7  import (
     8  	"errors"
     9  	"strconv"
    10  	"testing"
    11  )
    12  
    13  func BenchmarkSliceValidationError(b *testing.B) {
    14  	const size int = 100
    15  	for i := 0; i < b.N; i++ {
    16  		e := make(SliceValidationError, size)
    17  		for j := 0; j < size; j++ {
    18  			e[j] = errors.New(strconv.Itoa(j))
    19  		}
    20  		if len(e.Error()) == 0 {
    21  			b.Errorf("error")
    22  		}
    23  	}
    24  }
    25  

View as plain text