The designation Big-O is intended to describe how the algorithm behaves in the limit, as n goes to infinity. It is much easier to work in a theoretical study than in a practical experiment. I would choose things to study that you can easily measure that these people care, for example, about accuracy and computer resources (time / memory).
When you write and run a computer program to compare two algorithms, you perform a scientific experiment, like the one who measures the speed of light, or someone who compares the death rates from smokers and non-smokers, and many of them apply the same factors.
Try to select an example of a problem or problems to solve that are representative or at least interesting to you, because your results may not generalize to syntaxes that you have not actually tested. You can increase the range of situations that your results will answer if you arbitrarily make a choice from a large number of possible problems and find that all your random samples behave the same or at least adhere to the same trend. You can get unexpected results, even if theoretical studies show that there should be a good trend n log n, because theoretical studies rarely take into account a sudden cache out or out of memory, or usually even for things like integer overflow.
Be careful about the sources of errors and try to minimize them or apply to the same extent to all the things that you are comparing. Of course, you want to use exactly the same input for all the algorithms you are testing. Take a few runs of each algorithm and check how things are variable - maybe a few starts are slower because the computer was doing something else at a time. Keep in mind that caching can speed up subsequent algorithms, especially if you run them immediately after each other. What time you want depends on what you decide, you measure. If you have a lot of I / O, to remember that modern operating systems and computer cache have huge amounts of disk I / O in memory. Once I finished working with the computer again and again after each start, as the only way to make sure that the device I / O cache was reset.
source share