Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package zero
type Zero = struct{}
func New() Zero {
return Zero{}
}

View File

@@ -0,0 +1,42 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package zero_test
import (
"github.com/TeaOSLab/EdgeNode/internal/utils/zero"
"runtime"
"testing"
)
func TestZero_Chan(t *testing.T) {
var stat1 = &runtime.MemStats{}
runtime.ReadMemStats(stat1)
var m = make(chan zero.Zero, 2_000_000)
for i := 0; i < 1_000_000; i++ {
m <- zero.New()
}
var stat2 = &runtime.MemStats{}
runtime.ReadMemStats(stat2)
t.Log(stat2.HeapInuse, stat1.HeapInuse, stat2.HeapInuse-stat1.HeapInuse, "B")
t.Log(len(m))
}
func TestZero_Map(t *testing.T) {
var stat1 = &runtime.MemStats{}
runtime.ReadMemStats(stat1)
var m = map[int]zero.Zero{}
for i := 0; i < 1_000_000; i++ {
m[i] = zero.New()
}
var stat2 = &runtime.MemStats{}
runtime.ReadMemStats(stat2)
t.Log((stat2.HeapInuse-stat1.HeapInuse)/1024/1024, "MB")
t.Log(len(m))
_, ok := m[1024]
t.Log(ok)
}