Created
October 27, 2024 20:36
-
-
Save TylerBrock/93aebe1dd2659a094c6565a6fea06895 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unsafe" | |
) | |
type Key struct { // 32 + 12 = 44 bytes | |
t bool // 1 byte + 7 bytes padding | |
id string // 16 bytes + 12 bytes data for ObjectID values | |
hash uint32 // 4 bytes + 4 bytes padding | |
} | |
type OptimizedKey struct { | |
id string // 16 bytes + 12 bytes data for ObjectID values | |
hash uint32 // 4 bytes | |
t bool // 1 byte + 1 bytes padding | |
} | |
type Sum uint64 // 8 bytes | |
func main() { | |
old := Key{true, "", 0} | |
opt := OptimizedKey{"", 0, true} | |
fmt.Println(unsafe.Sizeof(old), unsafe.Sizeof(opt)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment