prof

package module
v0.0.0-...-6471263 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: MIT Imports: 4 Imported by: 0

README

prof

basic golang Go targeted profiling of specific functions / situations

Documentation

Overview

package prof provides very basic but effective profiling of targeted functions or code sections, which can often be more informative than generic cpu profiling

Here's how you use it:

// somewhere near start of program (e.g., using flag package)
profFlag := flag.Bool("prof", false, "turn on targeted profiling")
...
flag.Parse()
prof.Profiling = *profFlag
...
// surrounding the code of interest:
pr := prof.Start("name of function")
... code
pr.End()
...
// at end or whenever you've got enough data:
prof.Report(time.Millisecond) // or time.Second or whatever

Index

Constants

This section is empty.

Variables

View Source
var Prof = Profiler{}
View Source
var Profiling = false

Functions

func Report

func Report(units time.Duration)

Report generates a report of all the profile data collected

func Reset

func Reset()

Reset all data

Types

type Profile

type Profile struct {
	Name   string
	Tot    time.Duration
	N      int64
	Avg    float64
	St     time.Time
	Timing bool
}

func Start

func Start(name string) *Profile

Start starts profiling and returns a Profile struct that must have .End() called on it when done timing -- note will be nil if not the first to start timing on this function -- assumes nested inner / outer loop structure for calls to the same method

func (*Profile) End

func (p *Profile) End()

func (*Profile) Report

func (p *Profile) Report(tot, units float64)

func (*Profile) Start

func (p *Profile) Start() *Profile

type Profiler

type Profiler struct {
	Profs map[string]*Profile
	// contains filtered or unexported fields
}

Profiler manages a map of profiled functions

func (*Profiler) Report

func (p *Profiler) Report(units time.Duration)

Report generates a report of all the profile data collected

func (*Profiler) Reset

func (p *Profiler) Reset()

func (*Profiler) Start

func (p *Profiler) Start(name string) *Profile

Start starts profiling and returns a Profile struct that must have .End() called on it when done timing

Jump to

Keyboard shortcuts

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