Skip to content

Instantly share code, notes, and snippets.

@billglover
Last active September 18, 2018 15:23
Show Gist options
  • Save billglover/9aae5300129325488d72003ef72d069a to your computer and use it in GitHub Desktop.
Save billglover/9aae5300129325488d72003ef72d069a to your computer and use it in GitHub Desktop.
Increment an integer 1000 times (with a function call and no inlining)
package main
func main() {
n := inc(1000)
println(n)
}
func inc(n int) int {
for i := 0; i < 1000; i++ {
n = add(n)
}
return n
}
//go:noinline
func add(n int) int {
return n + 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment