-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnotes.txt
73 lines (48 loc) · 1.38 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Profiling
Maintainability X Performance
var products []Product
func FilterProducts() []Product{
var electronicsProducts []Product
for i:=; i < len(products); i++{
if products[i].Category == "Electronics" {
electronicsProducts = append(electronicsProducts, products[i])
}
}
return electronicsProducts
}
electronicsProducts := Products.Filter(func(p){
return p.Category == "Electronics"
})
func (products Products) Filter(predicate func(Product)bool ) Products {
var result []Product
for i:=; i < len(products); i++{
if predicate(products[i]) {
result = append(result, products[i])
}
}
return result
}
How?
Benchmarking
Tools
go toolset
load testing tools
ab
go-wrk
To run benchmark with memory
go test ./... -bench=. -benchmem
To generate the cpu profile
go test ./... -bench=. -benchmem -cpuprofile prof.cpu
commands used in the pprof terminal
top10
top10 -cum
list <function name>
To access the profile data using a web interface
go tool pprof -http=":8080" profiling-app.test prof.cp
To profile a web service
import _ "net/http/pprof"
load test the service using ab or go-wrk
while the load is still being applied
visit http://localhost:8080/debug/pprof/
to investigate the trace file
go tool trace sum.trace