Why does GCC generate a faster program than Clang in this recursive Fibonacci code?
问题 This is the code that I tested: #include <iostream> #include <chrono> using namespace std; #define CHRONO_NOW chrono::high_resolution_clock::now() #define CHRONO_DURATION(first,last) chrono::duration_cast<chrono::duration<double>>(last-first).count() int fib(int n) { if (n<2) return n; return fib(n-1) + fib(n-2); } int main() { auto t0 = CHRONO_NOW; cout << fib(45) << endl; cout << CHRONO_DURATION(t0, CHRONO_NOW) << endl; return 0; } Of course, there are much faster ways of calculating