Created
November 17, 2015 02:05
-
-
Save sheki/b231ac7e79b70d0711e8 to your computer and use it in GitHub Desktop.
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 boom_test | |
| import ( | |
| "testing" | |
| ) | |
| func BenchmarkHello(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| fibReadable(100000) | |
| } | |
| } | |
| func fibReadable(n uint) uint{ | |
| old := uint(0) | |
| current := uint(1) | |
| if n == 0 { | |
| return 0 | |
| } | |
| if n == 1 { | |
| return 1 | |
| } | |
| var temp uint | |
| for i :=uint(0); i < n-2; i++ { | |
| temp = current | |
| current = old + current | |
| old = temp | |
| } | |
| return current | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment