github.com/gogf/gf@v1.16.9/internal/structs/structs_z_bench_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package structs_test 8 9 import ( 10 "github.com/gogf/gf/internal/structs" 11 "testing" 12 ) 13 14 type User struct { 15 Id int 16 Name string `params:"name"` 17 Pass string `my-tag1:"pass1" my-tag2:"pass2" params:"pass"` 18 } 19 20 var ( 21 user = new(User) 22 userNilPointer *User 23 ) 24 25 func Benchmark_TagFields(b *testing.B) { 26 for i := 0; i < b.N; i++ { 27 structs.TagFields(user, []string{"params", "my-tag1"}) 28 } 29 } 30 31 func Benchmark_TagFields_NilPointer(b *testing.B) { 32 for i := 0; i < b.N; i++ { 33 structs.TagFields(&userNilPointer, []string{"params", "my-tag1"}) 34 } 35 }