Sujet : constexpr is really very smart!
De : student (at) *nospam* invalid.invalid (Student Project)
Groupes : comp.lang.c++Date : 15. Dec 2024, 21:20:42
Autres entêtes
Organisation : To protect and to server
Message-ID : <vjndub$2glcu$1@paganini.bofh.team>
The constexpr is really very smart because it can speed up algorithms
1000 times according to Dave, Microsoft retired engineer. He has proved it
by creating this video:
<
https://youtu.be/8-VZoXn8f9U?si=iy1UimoWcaLG31Xi>
On my computer it took 270 microseconds to calculate fib(35) like in his
example. It was almost instant at the blink of the eyes.
D:\CmdLine\C_Cpp\Chrono02>program
Fibonacci_c: 9227465
Time Taken: 270
D:\CmdLine\C_Cpp\Chrono02>program
Fibonacci_c: 9227465
Time Taken: 257
D:\CmdLine\C_Cpp\Chrono02>program
Fibonacci_c: 9227465
Time Taken: 171
D:\CmdLine\C_Cpp\Chrono02>program
Fibonacci_c: 9227465
Time Taken: 176
Amazing.