Make Loops More Efficient


Uncategorized

Updated Nov 17th, 2021

You can measure efficiency with big O.

You can also measure efficiency with timing tests. In the case of the lineup generator you can give two versions of the loop the same test you know a fail and see which one finishes quicker.

Testing Multiple Conditions

Instead of saying of calculating three metrics and then saying of this is met AND if this is met And if this is met do the following:

Calculate metric 1 and then test metric 1. If it doesn’t pass the test then quit execution.

Only if metric one passes its test do you even bother calculating metric two.

Something you consider is whether or not to nest if statements or using else if statement.

Something else to consider when you need to return an object when the condition fails You don’t want to repeat the object creation over and over and over again.

If there’s a start then filter by that start


Top