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() ... code pr.End() ... // at end or whenever you've got enough data: prof.Report(time.Millisecond) // or time.Second or whatever
Index ¶
Constants ¶
View Source
const ( // Version is the version of this package being used Version = "v2.0.0-dev0.0.6" // GitCommit is the commit just before the latest version commit GitCommit = "52366ed" // VersionDate is the date-time of the latest version commit in UTC (in the format 'YYYY-MM-DD HH:MM', which is the Go format '2006-01-02 15:04') VersionDate = "2024-01-09 01:20" )
Variables ¶
View Source
var Prof = Profiler{}
View Source
var Profiling = false
Functions ¶
Types ¶
type Profile ¶
func Start ¶
Start starts profiling and returns a Profile struct that must have Profile.End called on it when done timing. It will be nil if not the first to start timing on this function; it assumes nested inner / outer loop structure for calls to the same method. It uses the short, package-qualified name of the calling function as the name of the profile struct. Extra information can be passed to Start, which will be added at the end of the name in a dash-delimited format.
Click to show internal directories.
Click to hide internal directories.