init: v1.0.0

This commit is contained in:
yaole
2026-05-27 23:03:00 +08:00
commit 8d97f750eb
466 changed files with 80067 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
package main
import (
"sync"
"testing"
)
type SimpleStruct struct {
n int
}
func BenchmarkStructureFalseSharing(b *testing.B) {
structA := SimpleStruct{}
structB := SimpleStruct{}
wg := sync.WaitGroup{}
M := 1000000
b.ResetTimer()
for i := 0; i < b.N; i++ {
wg.Add(2)
go func() {
for j := 0; j < M; j++ {
structA.n += j
}
wg.Done()
}()
go func() {
for j := 0; j < M; j++ {
structB.n += j
}
wg.Done()
}()
wg.Wait()
}
}
func BenchmarkCopyAVX2(b *testing.B) {
a := make([]byte, 128*1024*1024)
c := make([]byte, 128*1024*1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
CopySlice_AVX2(a, c, len(c))
}
}
func BenchmarkCopy(b *testing.B) {
a := make([]byte, 128*1024*1024)
c := make([]byte, 128*1024*1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
CopySlice(a, c, len(c))
}
}