mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2026-06-21 00:46:51 +08:00
add example
This commit is contained in:
parent
2eda5cc663
commit
03e833dda4
1 changed files with 22 additions and 0 deletions
22
examples/stackannotate/main.go
Normal file
22
examples/stackannotate/main.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
func main() {
|
||||
var n int
|
||||
for i := 0; i < 10; i++ {
|
||||
n += foo(1)
|
||||
}
|
||||
println(n)
|
||||
<-chan struct{}(nil)
|
||||
}
|
||||
|
||||
func foo(a int) int {
|
||||
return bar(a, 2)
|
||||
}
|
||||
|
||||
func bar(a int, b int) int {
|
||||
s := 3
|
||||
for i := 0; i < 100; i++ {
|
||||
s += a * b
|
||||
}
|
||||
return s
|
||||
}
|
||||
Loading…
Reference in a new issue