Knowing when to optimize code in MATLAB
It is good to know how to write super-efficient algorithms, but it is even better to know if it is at all needed. There are two ways to think of speed: computation time and time to insight. We all know computation time is how long it takes to run the program. “Time to insight” is how long from when you start thinking about the program until you get an answer. If it takes me ten minutes to implement a slow version of an algorithm and I get my answer in one minute of calculation time, I am better off than the person who takes an hour to implement an algorithm that runs in 0.1 seconds. This is especially true if the problem only needs to be solved once.
In this example, I show how I throw together a proof of concept demo to find out if it even makes sense to try to make an efficient version of an algorithm. The answer will depend on size and scope of the problem, of course. It is the process that matters most.
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.