Comparison of stress and total energy methods for calculation of elastic properties of semiconductors