default_validator_benchmark_test.go
This file
Path
binding/default_validator_benchmark_test.go
27 lines · 494 bytes · Go
Last changed by
refactor: use b.Loop() to simplify the code and improve performance (#4432)efckingbefore adoptiona85ef5c
History of this fileTake it
1// Copyright 2022 Gin Core Team. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package binding67import (8 "errors"9 "strconv"10 "testing"11)1213func BenchmarkSliceValidationError(b *testing.B) {14 const size int = 10015 e := make(SliceValidationError, size)16 for j := 0; j < size; j++ {17 e[j] = errors.New(strconv.Itoa(j))18 }1920 b.ReportAllocs()2122 for b.Loop() {23 if len(e.Error()) == 0 {24 b.Errorf("error")25 }26 }27}