Skip to content

Instantly share code, notes, and snippets.

@life1347
Last active May 30, 2019 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save life1347/fe79903dcad9673d8045ca24fccf5102 to your computer and use it in GitHub Desktop.
Save life1347/fe79903dcad9673d8045ca24fccf5102 to your computer and use it in GitHub Desktop.
$ go run ./p7uGl0JZ_TR.go
NoEmbedStruct
without pool: 1.558109ms
with pool: 89.337184ms
EmbedStruct
without pool: 651.618531ms
with pool: 84.505615ms
# https://stackoverflow.com/questions/45003259/passing-an-optimization-flag-to-a-go-compiler
# -N : Disable optimizations
# -l : Disable inlining
$ go run -gcflags '-N -l' ./p7uGl0JZ_TR.go
NoEmbedStruct
without pool: 139.720966ms
with pool: 97.43476ms
EmbedStruct
without pool: 672.334312ms
with pool: 91.052924ms
# new(Data) 改寫成 Data{b:make([]byte, 1024)}
$ go run ./p7uGl0JZ_TR.go
NoEmbedStruct
without pool: 1.330158ms
with pool: 82.081171ms
EmbedStruct
without pool: 1.304114ms
with pool: 80.288109ms
$ go run -gcflags '-N -l' ./p7uGl0JZ_TR.go
NoEmbedStruct
without pool: 136.941637ms
with pool: 94.261001ms
EmbedStruct
without pool: 102.397449ms
with pool: 89.48266ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment