From 1b496432df1dc28b25eaeadec5fa537aaf014f98 Mon Sep 17 00:00:00 2001 From: a73x Date: Sun, 25 Aug 2024 15:14:42 +0100 Subject: feat(post): templating add templating for posts and first post --- posts/001.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 posts/001.md (limited to 'posts/001.md') diff --git a/posts/001.md b/posts/001.md new file mode 100644 index 0000000..9942c2f --- /dev/null +++ b/posts/001.md @@ -0,0 +1,35 @@ +--- +title: "Go Benchmarking" +--- +## Benchmarking +1. write a benchmark +2. run a benchmark +3. get a profile +4. optimise +5. run your tests +6. goto 2. +### cpuprofile +`go test -test=XXX -bench -cpuprofile ` + +### memprofile +`go test -test=XXX -bench -memprofile -benchmem` + +### pprof +[pprof usage](https://github.com/google/pprof/blob/main/doc/README.md) + +`go pprof -http=:8080 profile.pb.gz` +will show a web UI for analysing the profile. + +#### views: +- flame graph: `localhost:8080/ui/flamegraph` + - shows percentage breakdown of how much resource each "call" made. + - clicking a box will make it "100%" allowing for deep diving + - right click "show source code" to view +- top: `localhost:8080/ui/top` + - shows top functions + - `flat`: profile samples in this function + - `cum`: (cumulative) profile samples in this function and its callees +- source: `localhost:8080/ui/source` + - each source line is annotated with the time spent in that source line + - the first number does not count time spent in functions called from the source line + - the second number does \ No newline at end of file -- cgit v1.2.3