Skip to content

Instantly share code, notes, and snippets.

@life1347
Last active May 30, 2019 08:00
Show Gist options
  • Save life1347/fe79903dcad9673d8045ca24fccf5102 to your computer and use it in GitHub Desktop.
Save life1347/fe79903dcad9673d8045ca24fccf5102 to your computer and use it in GitHub Desktop.

Revisions

  1. life1347 revised this gist May 30, 2019. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,10 @@ 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
    @@ -16,7 +20,7 @@ EmbedStruct
    without pool: 672.334312ms
    with pool: 91.052924ms

    new(Data) 變成 Data{b:make([]byte, 1024)}
    # new(Data) 改寫成 Data{b:make([]byte, 1024)}

    $ go run ./p7uGl0JZ_TR.go
    NoEmbedStruct
  2. life1347 revised this gist May 30, 2019. 1 changed file with 21 additions and 1 deletion.
    22 changes: 21 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,24 @@ with pool: 97.43476ms

    EmbedStruct
    without pool: 672.334312ms
    with pool: 91.052924ms
    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
  3. life1347 revised this gist May 30, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    $ go run ~/Downloads/p7uGl0JZ_TR.go
    $ go run ./p7uGl0JZ_TR.go
    NoEmbedStruct
    without pool: 1.558109ms
    with pool: 89.337184ms
    @@ -7,7 +7,7 @@ EmbedStruct
    without pool: 651.618531ms
    with pool: 84.505615ms

    $ go run -gcflags '-N -l' ~/Downloads/p7uGl0JZ_TR.go
    $ go run -gcflags '-N -l' ./p7uGl0JZ_TR.go
    NoEmbedStruct
    without pool: 139.720966ms
    with pool: 97.43476ms
  4. life1347 created this gist May 30, 2019.
    17 changes: 17 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    $ go run ~/Downloads/p7uGl0JZ_TR.go
    NoEmbedStruct
    without pool: 1.558109ms
    with pool: 89.337184ms

    EmbedStruct
    without pool: 651.618531ms
    with pool: 84.505615ms

    $ go run -gcflags '-N -l' ~/Downloads/p7uGl0JZ_TR.go
    NoEmbedStruct
    without pool: 139.720966ms
    with pool: 97.43476ms

    EmbedStruct
    without pool: 672.334312ms
    with pool: 91.052924ms