-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
There is something wrong with the story about Fibonacci benchmarks presented in the compiled view here https://dave.cheney.net/high-performance-go-workshop/dotgo-paris.htm
First, you have the example of an unoptimized Fibonacci algorithm
func Fib(n int) int {
switch n {
case 0:
return 0
case 1:
return 1
case 2:
return 2
default:
return Fib(n-1) + Fib(n-2)
}
}Despite it is wrong and provides incorrect result maybe it's made intentionally. But then you have a slightly optimized version on the paragraph 2.3.1. Improve Fib
func Fib(n int) int {
switch n {
case 0:
return 0
case 1:
return 1
case 2:
return 1
default:
return Fib(n-1) + Fib(n-2)
}
}It's a correct working version of the algorithm but they are equal from the performance point of view, so the point about some optimization looks strange
Metadata
Metadata
Assignees
Labels
No labels