// ------------------------------------------------------------------------ // â„šī¸ Project active3 // Active Thing (activething.com) git.activething.com/go // // File name Newfield_benchmark_test.go // âœī¸ Created by DEV // 📅 Modified 01/05/2024 // // 🔒 COPYRIGHT Copyright 2024 activething.com // ------------------------------------------------------------------------ // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ------------------------------------------------------------------------ package AATest import ( "aflds" "testing" ) func BenchmarkA (b *testing.B) { for i := 0; i < b.N; i++ { aflds.NewFieldString("f1", "value") aflds.NewFieldUint("f2", 11) aflds.NewFieldInt("f3", -11) aflds.NewFieldFloat("f4", 2.3) aflds.NewFieldBinary("f5", []byte{1,2,2,4,3,3,3,3}) aflds.NewDFieldInt("d1",func()int{ return -3 }) aflds.NewDFieldUint("d2",func()uint{ return uint(3) }) aflds.NewDFieldFloat("f2",func()float64{ return 3.2}) } } func BenchmarkB (b *testing.B) { for i := 0; i < b.N; i++ { aflds.Create("f1", "value",aflds.KindString) aflds.Create("f2", uint(11),aflds.KindUint) aflds.Create("f3", -11,aflds.KindInt) aflds.Create("f4", 2.3,aflds.KindFloat) aflds.Create("f5", []byte{1,2,2,4,3,3,3,3},aflds.KindBinary) aflds.Create("d1",func()int{ return -3 },aflds.KindDeferInt) aflds.Create("d2",func()uint{ return uint(3) },aflds.KindDeferUint) aflds.Create("f2",func()float64{ return 3.2},aflds.KindDeferFloat) } } func BenchmarkC (b *testing.B) { for i := 0; i < b.N; i++ { aflds.CreateFromValue("f1", "value") aflds.CreateFromValue("f2", 11) aflds.CreateFromValue("f3", -11) aflds.CreateFromValue("f4", 2.3) aflds.CreateFromValue("f5", []byte{1,2,2,4,3,3,3,3}) aflds.CreateFromValue("d1",func()int{ return -3 }) aflds.CreateFromValue("d2",func()uint{ return 3 }) aflds.CreateFromValue("f2",func()float64{ return 3.2}) } }