02_with-CPU-Profiler

command
v0.0.0-...-baf0b24 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 12 Imported by: 0

README

With CPU Profiling

This one we have the same programer as 01_Initial-No-Profiler , but with an added file generated for profiling.

This file is done using the following:

...
	// Create a Profiling File
	fl, err := os.Create("p.out")
	if err != nil {
		panic(err)
	}
	defer fl.Close()
	// Begin CPU Profiling
	pprof.StartCPUProfile(fl)
  defer pprof.StopCPUProfile()
...

These lines would create a file p.out containing the Profile info.

Using golang internal tool called pprof we can visualize whats going On.

Profiling Command

go tool pprof -http :6000 p.out

This command would instantly open your Web-browser. It would show the timing and profile graph of the execution.

Note: The option -http opens up the pprof server User interface. In case one is interested in doing detail analysis in command line - you can also get a (pprof) prompt by removing it.

Conclusion

Though the details displayed are stunning but one can hardly image the actual bottle necks.

To some extent one can observe the more time taking function. But the integrated effect of goroutines + Workloads can't be visualized.

Documentation

Overview

* After running the program

Use command to view profile:

go tool pprof -http :6000 p.out

Jump to

Keyboard shortcuts

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