Last active
September 6, 2019 17:18
-
-
Save blanchonvincent/d4ed01d31b3ed99eb5cd87629ecfe926 to your computer and use it in GitHub Desktop.
Medium - Instrumentation statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "math/rand" | |
func main() { | |
println(run()) | |
} | |
//go:noinline | |
func run() int { | |
a := 0 | |
for i:= 0; i < rand.Intn(100000); i++ { | |
if i % 2 == 0 { | |
add(&a) | |
} else { | |
sub(&a) | |
} | |
} | |
return a | |
} | |
//go:noinline | |
func add(a *int) { | |
*a += rand.Intn(10) | |
} | |
//go:noinline | |
func sub(a *int) { | |
*a -= rand.Intn(10) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment