Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e65636f

Browse files
空结构体
1 parent 4390681 commit e65636f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package datastructure
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
"unsafe"
7+
)
8+
9+
func TestSizeOfEmptyStructTest(t *testing.T) {
10+
fmt.Println(unsafe.Sizeof(struct{}{}))
11+
}

‎performance_rule/readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,12 @@ cpu: AMD Ryzen 5 4600U with Radeon Graphics
8888
| ------------------------------------------------------------ | ------------------------------------------------------------ |
8989
| [iterate_struct_pointer_test.go](datastructure/iterate_struct_pointer_test.go) | [iterate_struct_pointer_test.md](datastructure/iterate_struct_pointer_test.md) |
9090

91+
## 内存管理
92+
93+
### 1.使用空结构体节省内存
94+
95+
#### 1.1 不占内存空间
96+
97+
| 代码 | 验证结果 |
98+
| ------------------------------------------------------------ | -------- |
99+
| [size_of_empty_struct_test.go](datastructure/size_of_empty_struct_test.go) | 0 |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /