summaryrefslogtreecommitdiff
path: root/content/posts/001.md
diff options
context:
space:
mode:
authora73x <[email protected]>2024-08-27 19:43:56 +0100
committera73x <[email protected]>2024-08-27 20:23:18 +0100
commitd38fc83df3824b840f0b3930e4cb7236bdab84b2 (patch)
tree586a7f940291f933ef2a7e05b20dff21ded6d78a /content/posts/001.md
parentcffb105a9ff8ed5d7aa04e5f4097368f6be38b8e (diff)
feat(content): support templating in content
this is tired person code don't write tired person code
Diffstat (limited to 'content/posts/001.md')
-rw-r--r--content/posts/001.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/content/posts/001.md b/content/posts/001.md
new file mode 100644
index 0000000..48ea720
--- /dev/null
+++ b/content/posts/001.md
@@ -0,0 +1,36 @@
+---
+title: "Go Benchmarking"
+tags: posts
+---
+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 <regex> -cpuprofile <file>`
+
+## memprofile
+`go test -test=XXX -bench <regex> -memprofile <file> -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