From 8697555125c57ae64a0c9b78514b4aac4fd523de Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 27 Jun 2023 14:50:20 +0200 Subject: Massive formatting and added figcaption --- .../2017-03-07-golang-profiling-simplified.md | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'content/posts/2017-03-07-golang-profiling-simplified.md') 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 --- Many posts have been written regarding profiling in Golang and I haven’t found -proper tutorial regarding this. Almost all of them are missing some part of -important information and it gets pretty frustrating when you have a deadline +proper tutorial regarding this. Almost all of them are missing some part of +important information and it gets pretty frustrating when you have a deadline and are not finding simple distilled solution. -Nevertheless, after searching and experimenting I have found a solution that +Nevertheless, after searching and experimenting I have found a solution that works for me and probably should also for you. ## Where are my pprof files? -By default pprof files are generated in /tmp/ folder. You can override folder -where this files are generated programmatically in your golang code as we will +By default pprof files are generated in /tmp/ folder. You can override folder +where this files are generated programmatically in your golang code as we will see below in example. ## Why is my CPU profile empty? -I have found out that sometimes CPU profile is empty because program was not -executing long enough. Programs, that execute too quickly don’t produce pprof +I have found out that sometimes CPU profile is empty because program was not +executing long enough. Programs, that execute too quickly don’t produce pprof file in my cases. Well, file is generated but only contains 4KB of information. ## Profiling -As you can see from examples we are executing dummy_benchmark functions to -ensure some sort of execution. Memory profiling can be done without such a +As you can see from examples we are executing dummy_benchmark functions to +ensure some sort of execution. Memory profiling can be done without such a “complex” function. But CPU profiling needs it. -Both memory and CPU profiling examples are almost the same. Only parameters -in main function when calling profile.Start are different. When we set -profile.ProfilePath(“.”) we tell profiler to store pprof files in the same +Both memory and CPU profiling examples are almost the same. Only parameters in +main function when calling profile.Start are different. When we set +profile.ProfilePath(“.”) we tell profiler to store pprof files in the same folder as our program. ### Memory profiling -- cgit v1.2.3