profiling

command
v0.0.0-...-ae246d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

Benchmark Profiling

Using benchmarks you can profile your programs and see exactly where your performance or memory is being taken.

Profiling Commands

CPU Profiling
   go test -run none -bench . -cpuprofile cpu.out
   go tool pprof profiling.test cpu.out
   
      (pprof) list getValue

      10ms       10ms     36:func getValue(variable string, vars map[string]string) interface{} {
         .          .     37:
         .          .     38: // variable: "#cmd:variable_name"
         .          .     39:
         .          .     40: // Trim the # symbol from the string.
      10ms      260ms     41: value := strings.TrimLeft(variable, "#")

   go tool pprof -pdf profiling.test cpu.out > cpu.pdf
   open -a "Adobe Acrobat" mem.pdf
Memory Profiling
   go test -run none -bench . -memprofile mem.out -memprofilerate 1 -benchmem
   go tool pprof -alloc_space profiling.test mem.out

      (pprof) list getValue

      .          .     36:func getValue(variable string, vars map[string]string) interface{} {
      .          .     37:
      .          .     38: // variable: "#cmd:variable_name"
      .          .     39:
      .          .     40: // Trim the # symbol from the string.
      .     6.41MB     41: value := strings.TrimLeft(variable, "#")
   
   go tool pprof -pdf -alloc_space profiling.test mem.out > mem.pdf
   open -a "Adobe Acrobat" mem.pdf

   -inuse_space  : Display in-use memory size
   -inuse_objects: Display in-use object counts
   -alloc_space  : Display allocated memory size
   -alloc_objects: Display allocated object counts

Code Review

Profiling (Go Playground) | Profiling Test (Go Playground)


All material is licensed under the Apache License Version 2.0, January 2004.

Documentation

Overview

Test program for the benchmark example.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL