|
|
// ------------------------------------------------------------------------
|
|
|
// ℹ️ 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 AATest
|
|
|
|
|
|
import (
|
|
|
"acache"
|
|
|
"aflds"
|
|
|
"fields"
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
|
|
|
func BenchmarkAflds (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 BenchmarkAcache (b *testing.B) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
|
acache.NewFieldString("f1", "value")
|
|
|
acache.NewFieldUint("f2", 11)
|
|
|
acache.NewFieldInt("f3", -11)
|
|
|
acache.NewFieldFloat("f4", 2.3)
|
|
|
acache.NewFieldBinary("f5", []byte{1,2,2,4,3,3,3,3})
|
|
|
acache.NewDFieldInt("d1",func()int{ return -3 })
|
|
|
acache.NewDFieldUint("d2",func()uint{ return uint(3) })
|
|
|
acache.NewDFieldFloat("f2",func()float64{ return 3.2})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
func BenchmarkAFields (b *testing.B) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
|
|
fields.NewFieldString("f1", "value")
|
|
|
fields.NewFieldUint("f2", 11)
|
|
|
fields.NewFieldInt("f3", -11)
|
|
|
fields.NewFieldFloat("f4", 2.3)
|
|
|
fields.NewFieldBinary("f5", []byte{1,2,2,4,3,3,3,3})
|
|
|
fields.NewDFieldInt("d1",func()int{ return -3 })
|
|
|
fields.NewDFieldUint("d2",func()uint{ return uint(3) })
|
|
|
fields.NewDFieldFloat("f2",func()float64{ return 3.2})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
func BenchmarkA1 (b *testing.B) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
aflds.NewDFieldString("f1", func() string { return "value" })
|
|
|
aflds.NewDFieldUint("f2", func () uint { return uint(11) })
|
|
|
aflds.NewDFieldInt("f3", func () int { return -11 })
|
|
|
aflds.NewDFieldFloat("f4",func() float64 { return 2.3 })
|
|
|
aflds.NewDFieldBinary("f5",func() []byte { return []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 BenchmarkAfldsAcc (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []aflds.Field {
|
|
|
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}),
|
|
|
}
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
for i:=0; i<8; i++ {
|
|
|
d[i]=flds[i].Value()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func BenchmarkAcacheAcc (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []acache.Field {
|
|
|
acache.NewDFieldString("f1", func() string { return "value" }),
|
|
|
acache.NewDFieldUint("f2", func () uint { return uint(11) }),
|
|
|
acache.NewDFieldInt("f3", func () int { return -11 }),
|
|
|
acache.NewDFieldFloat("f4",func() float64 { return 2.3 }),
|
|
|
acache.NewDFieldBinary("f5",func() []byte { return []byte{1,2,2,4,3,3,3,3} }),
|
|
|
acache.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
acache.NewDFieldUint("d2",func()uint{ return uint(3) }),
|
|
|
acache.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 BenchmarkAFieldsAcc (b *testing.B) {
|
|
|
var d[8]any
|
|
|
flds := []fields.Field {
|
|
|
fields.NewDFieldString("f1", func() string { return "value" }),
|
|
|
fields.NewDFieldUint("f2", func () uint { return uint(11) }),
|
|
|
fields.NewDFieldInt("f3", func () int { return -11 }),
|
|
|
fields.NewDFieldFloat("f4",func() float64 { return 2.3 }),
|
|
|
fields.NewDFieldBinary("f5",func() []byte { return []byte{1,2,2,4,3,3,3,3} }),
|
|
|
fields.NewDFieldInt("d1",func()int{ return -3 }),
|
|
|
fields.NewDFieldUint("d2",func()uint{ return uint(3) }),
|
|
|
fields.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 BenchmarkA2 (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 BenchmarkA3 (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})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*/ |