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

Delveを用いたデバッグ & pprofを用いたプロファイリング

Delveを用いたデバッグ & pprofを用いたプロファイリング

golang.tokyo #23 https://golangtokyo.connpass.com/event/126673/
20:20 ~ 20:40「Delveを用いたデバッグ & pprofを用いたプロファイリング」の発表資料です。

Hikaru Watanabe

April 19, 2019
Tweet

More Decks by Hikaru Watanabe

Other Decks in Programming

Transcript

  1. & D

  2. 02 /1 • • W 4 4 IS M h

    I ? • 8 // 9 • ? a 79B B • O V
  3. -1 -D • 1 . I : • / 5

    % . / . -1 - -1 - • • G • G • G • - • 11 . .- . / . -1 - -1 - 1
  4. 1 • ( . : D package main import (

    "fmt" ) func main() { array := [4]string{} fruits := []string{ "apple", "orange", "grape", "kiwi", "pineapple", } for i, f := range fruits { array[i] = f } fmt.Printf("%#v", array) } panic: runtime error: index out of range goroutine 1 [running]: main.main() /tmp/sandbox760713094/main.go:17 +0x160 Program exited: status 2. : : • ) (/ 1(. : ac • 7. : D • 67 b • . 7 f e
  5. • 2 1 7 / ( ) package main import

    ( "fmt" "runtime" ) func main() { array := [4]string{} fruits := []string{ "apple", "orange", "grape", "kiwi", "pineapple", } for i, f := range fruits { // Breakpoint  runtime.Breakpoint() array[i] = f } fmt.Printf("%#v", array) }
  6. • / /CG SR D • / :2 ) 2

    / 8: 8 : / • ( L
  7. • . • W 9 G S • / •

    • • / . • /
  8. . ) 01 . 1 5 5 5 5 5

    5 ) .5( 0: $ package main import ( "fmt" "github.com/pkg/profile" ) func fib(n int) int { if n < 2 { return n } return fib(n-1) + fib(n-2) } func main() { defer profile.Start(profile.ProfilePath(".")).Stop() fmt.Println("Start") for i := 0; i < 1000; i++ { fib(50) } fmt.Println("Finish") }
  9. • B 1 • 1 • 1 • 1 1

    • 1 • 2 C 1 (e.g. go tool pprof --text pprof/test.bin pprof/cpu.out)
  10. • 1 A • N : 4.A • /4 D

    ! • 088 3 433 42 38