Last active
September 18, 2018 15:23
-
-
Save billglover/9aae5300129325488d72003ef72d069a to your computer and use it in GitHub Desktop.
Increment an integer 1000 times (with a function call and no inlining)
This file contains hidden or 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 | |
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