Efficiency is defined as the ratio of the power output to the power input.
η=PoutPin.
Since power is the rate of doing work and the 2 powers occur for the same time while the machine operates, we may also then write efficiency as the ratio of the energy output to the energy input.
η=WoutWin