Efficiency of Code Functionally Similar to if()

Posted by Eclipse1255@reddit | learnprogramming | View on Reddit | 4 comments

I want to know how efficient (or inefficient) if statements are to their alternatives and in what ways. I'm certain there are many alternatives I don't know---and I do want to hear about them---but in particular the following two ways.

To keep it simple, assume x is either 0 or 1 and thisFunction() does something. Before the two ways, the if statement I'll translate:

if x==1:

thisFunction()

#Code End

for i in range(x):

thisFunction()

#Code End

list=[doesNothing, thisFunction]

list[x]()

#Code End

Aside from if statement alternatives, what are ways I can compare the efficiency of two segments of code?