Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance em Go

Performance em Go

Algumas técnicas para otimizar seu programas em Go, esta apresentação retrata algumas técnicas que poderão ser utilizadas no seu dia a dia para otimizar ainda mais seus códigos em Go.
Utilização do Sync.Pool, pprof, Benchmarking.

Jefferson Otoni Lima

July 25, 2019
Tweet

More Decks by Jefferson Otoni Lima

Other Decks in Technology

Transcript

  1. http://s3wf.com
    @jeffotoni
    2019 BELO HORIZONTE 25/07
    Jefferson Otoni
    Performance

    View Slide

  2. @jeffotoni
    Benchmarks
    Use strings.Builder em Go
    01
    03
    04
    Otimizar programas Go
    05
    06
    07
    Use sync.Pool
    Como escrever benchmarks em Go
    02
    Pprof
    Evite usar map[string]int

    View Slide

  3. - Compilada e estática
    - Gc (Garbage Collector)
    - Paradigma Concorrente
    - Tipagem estática
    - Semântica é clara
    - Sintaxe é limpa
    - É de uso Geral
    - Plataformas: Windows,
    Linux, Mac e FreeBSD
    Características

    View Slide

  4. Use
    sync.Pool

    View Slide

  5. reduzir
    número de
    alocações
    salvos

    View Slide

  6. Evite usar
    map[string]int

    View Slide

  7. lento
    fast

    View Slide

  8. lento
    fast

    View Slide

  9. use
    strings.Builder

    View Slide

  10. fast
    lento

    View Slide

  11. View Slide

  12. Use
    strconv

    View Slide

  13. fast
    lento

    View Slide

  14. View Slide

  15. Use
    Make
    evitar realocação

    View Slide

  16. danger
    fast
    better
    good

    View Slide

  17. Benchmark

    View Slide

  18. “testing”
    *testing.B

    View Slide

  19. *testing.T

    View Slide

  20. View Slide

  21. pprof

    View Slide

  22. -> go tool pprof --text ./gostring.test cpu.pprof
    -> pprof -http=localhost:6060 pprof-2 cpu.pprof

    View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. referências
    https://github.com/jeffotoni/goexample/tree/master/performance
    Sources da apresentação
    https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go
    https://golang.org/pkg/testing/
    https://golang.org/pkg/net/http/pprof/
    https://blog.golang.org/profiling-go-programs
    https://medium.com/justforfunc/analyzing-the-performance-of-go-functions-with-benchmarks-60b8162e61c6
    links

    View Slide

  27. Thanks := &Obrigado{...}
    Obrigado...
    github.com/jeffotoni
    instagram.com/jeffotoni
    https://t.me/devopsbh
    https://t.me/go_br
    https://t.me/awsbrasil
    linkedin.com/in/jeffotoni/

    View Slide