From 7a89158593e62b102f67e95a9e62eeafc55c3d0d Mon Sep 17 00:00:00 2001 From: Zhang-Jun-tao <369090720@qq.com> Date: Tue, 15 Feb 2022 09:59:22 +0800 Subject: [PATCH] fix linear_alloc_test.go --- example/mod/go.mod | 5 ----- example/mod/go.sum | 5 ----- src/README | 1 - src/linear_alloc_test.go | 9 ++++----- 4 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 example/mod/go.mod delete mode 100644 example/mod/go.sum delete mode 100644 src/README diff --git a/example/mod/go.mod b/example/mod/go.mod deleted file mode 100644 index 65bffab..0000000 --- a/example/mod/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module xmm - -go 1.12 - -require github.com/spf13/cast v1.4.1 diff --git a/example/mod/go.sum b/example/mod/go.sum deleted file mode 100644 index 963216d..0000000 --- a/example/mod/go.sum +++ /dev/null @@ -1,5 +0,0 @@ -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/src/README b/src/README deleted file mode 100644 index 8b13789..0000000 --- a/src/README +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/linear_alloc_test.go b/src/linear_alloc_test.go index c78ba3e..7d32370 100644 --- a/src/linear_alloc_test.go +++ b/src/linear_alloc_test.go @@ -65,7 +65,7 @@ func TestLinearAlloc2(t *testing.T) { if err != nil { t.Fatal(err) } - node := (*entry.NodeEntry)(p) + node := (*NodeEntry)(p) var wait sync.WaitGroup wait.Add(10) @@ -99,14 +99,14 @@ func TestLinearAlloc3(t *testing.T) { if err != nil { t.Fatal(err) } - fmt.Println(unsafe.Sizeof(entry.NodeEntry{}), uintptr(p), round(uintptr(p), pageSize), unsafe.Offsetof(entry.NodeEntry{}.Next)) - fmt.Println(round(unsafe.Sizeof(entry.NodeEntry{}), 8), round(unsafe.Sizeof(A{}), 8)) + fmt.Println(unsafe.Sizeof(NodeEntry{}), uintptr(p), round(uintptr(p), pageSize), unsafe.Offsetof(NodeEntry{}.Next)) + fmt.Println(round(unsafe.Sizeof(NodeEntry{}), 8), round(unsafe.Sizeof(A{}), 8)) //todo 怀疑是这个内存没有对齐 -120 cache line 0.01s -80 0.09s -20 0.22s //todo 对齐 ptr := uintptr(p) + pageSize*101 - 1500 fmt.Println(ptr, ptr%8, round(ptr, pageSize), round(ptr+80, pageSize)) - node := (*entry.NodeEntry)(unsafe.Pointer(ptr)) + node := (*NodeEntry)(unsafe.Pointer(ptr)) var wait sync.WaitGroup wait.Add(10) t11 := time.Now() @@ -137,5 +137,4 @@ func TestLinearCopyAlloc4(t *testing.T) { } ptr := uintptr(p) + pageSize*101 - 1500 fmt.Println(float64(pageSize*101)*0.1/8.0, ptr) - }