profile

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

A couple of simple helper functions to make it easy to get CPU or blocking profile data from your tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProfileBlockings

func ProfileBlockings(file string) func()

To save block profile data (how much time is being spent waiting) from your program, add code like the following to your main() function:

import(
    "os"
    "github.com/TyeMcQueen/go-tutl/profile"
)

func main() {
    // ...
    if path := os.Getenv("BLOCK_PROFILE"); "" != path {
        go tutl.ShowStackTraceOnInterrupt(false)
        defer profile.ProfieBlockings(path)()
    }
    // ...
}

The call to ShowStackOnInterrupt() ensures the blocking profile data will be saved even if you interrupt (SIGINT, Ctrl-C) your test run.

func ProfileCPU

func ProfileCPU(file string) func()

To save CPU profile data from your program, add code like the following to your main() function:

import(
    "os"
    "github.com/TyeMcQueen/go-tutl"
    "github.com/TyeMcQueen/go-tutl/profile"
)

func main() {
    // ...
    if path := os.Getenv("CPU_PROFILE"); "" != path {
        go tutl.ShowStackTraceOnInterrupt(false)
        defer profile.ProfieCPU(path)()
    }
    // ...
}

The call to ShowStackOnInterrupt() ensures the CPU profile data will be properly flushed even if you interrupt (SIGINT, Ctrl-C) your test run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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