aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2017-03-07-golang-profiling-simplified.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2017-03-07-golang-profiling-simplified.md')
-rw-r--r--content/posts/2017-03-07-golang-profiling-simplified.md24
1 files changed, 12 insertions, 12 deletions
diff --git a/content/posts/2017-03-07-golang-profiling-simplified.md b/content/posts/2017-03-07-golang-profiling-simplified.md
index 7eee2dd..4bd18b2 100644
--- a/content/posts/2017-03-07-golang-profiling-simplified.md
+++ b/content/posts/2017-03-07-golang-profiling-simplified.md
@@ -6,34 +6,34 @@ draft: false
6--- 6---
7 7
8Many posts have been written regarding profiling in Golang and I haven’t found 8Many posts have been written regarding profiling in Golang and I haven’t found
9proper tutorial regarding this. Almost all of them are missing some part of 9proper tutorial regarding this. Almost all of them are missing some part of
10important information and it gets pretty frustrating when you have a deadline 10important information and it gets pretty frustrating when you have a deadline
11and are not finding simple distilled solution. 11and are not finding simple distilled solution.
12 12
13Nevertheless, after searching and experimenting I have found a solution that 13Nevertheless, after searching and experimenting I have found a solution that
14works for me and probably should also for you. 14works for me and probably should also for you.
15 15
16## Where are my pprof files? 16## Where are my pprof files?
17 17
18By default pprof files are generated in /tmp/ folder. You can override folder 18By default pprof files are generated in /tmp/ folder. You can override folder
19where this files are generated programmatically in your golang code as we will 19where this files are generated programmatically in your golang code as we will
20see below in example. 20see below in example.
21 21
22## Why is my CPU profile empty? 22## Why is my CPU profile empty?
23 23
24I have found out that sometimes CPU profile is empty because program was not 24I have found out that sometimes CPU profile is empty because program was not
25executing long enough. Programs, that execute too quickly don’t produce pprof 25executing long enough. Programs, that execute too quickly don’t produce pprof
26file in my cases. Well, file is generated but only contains 4KB of information. 26file in my cases. Well, file is generated but only contains 4KB of information.
27 27
28## Profiling 28## Profiling
29 29
30As you can see from examples we are executing dummy_benchmark functions to 30As you can see from examples we are executing dummy_benchmark functions to
31ensure some sort of execution. Memory profiling can be done without such a 31ensure some sort of execution. Memory profiling can be done without such a
32“complex” function. But CPU profiling needs it. 32“complex” function. But CPU profiling needs it.
33 33
34Both memory and CPU profiling examples are almost the same. Only parameters 34Both memory and CPU profiling examples are almost the same. Only parameters in
35in main function when calling profile.Start are different. When we set 35main function when calling profile.Start are different. When we set
36profile.ProfilePath(“.”) we tell profiler to store pprof files in the same 36profile.ProfilePath(“.”) we tell profiler to store pprof files in the same
37folder as our program. 37folder as our program.
38 38
39### Memory profiling 39### Memory profiling