|
|
// ------------------------------------------------------------------------
|
|
|
// ℹ️ 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.
|
|
|
// ------------------------------------------------------------A------------
|
|
|
|
|
|
package test
|
|
|
|
|
|
import (
|
|
|
"flds"
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
|
|
|
func BenchmarkAflds (b *testing.B) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
|
flds.NewFieldString("f1", "value")
|
|
|
flds.NewFieldUint("f2", 11)
|
|
|
flds.NewFieldInt("f3", -11)
|
|
|
flds.NewFieldFloat("f4", 2.3)
|
|
|
flds.NewFieldBinary("f5", []byte{1,2,2,4,3,3,3,3})
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 })
|
|
|
flds.NewDFieldUint("d2",func()uint{ return uint(3) })
|
|
|
flds.NewDFieldFloat("f2",func()float64{ return 3.2})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func BenchmarkAfldsAcc (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []flds.Field {
|
|
|
flds.NewFieldString("f1", "value"),
|
|
|
flds.NewFieldUint("f2", 11),
|
|
|
flds.NewFieldInt("f3", -11),
|
|
|
flds.NewFieldFloat("f4", 2.3),
|
|
|
flds.NewFieldBinary("f5", []byte{1,2,2,4,3,3,3,3}),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldUint("d2",func()uint{ return uint(3) }),
|
|
|
flds.NewDFieldFloat("f2",func()float64{ return 3.2}),
|
|
|
}
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
for i:=0; i<8; i++ {
|
|
|
d[i]=flds[i].Value()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
func BenchmarkAfldsAcDf (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []flds.Field {
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
}
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
for i:=0; i<8; i++ {
|
|
|
d[i]=flds[i].Value()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func BenchmarkAfldsAcDo (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []flds.Field {
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
}
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
for i:=0; i<8; i++ {
|
|
|
d[i]=flds[i].Value()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
func BenchmarkAfldsAcDo1 (b *testing.B) {
|
|
|
flds := []flds.Field {
|
|
|
flds.NewDOFieldInt("d1",func()int{ return -3 }),
|
|
|
}
|
|
|
flds[0].Value()
|
|
|
|
|
|
|
|
|
}
|