Created
July 24, 2013 03:50
-
-
Save Fhernd/6067950 to your computer and use it in GitHub Desktop.
Demostración de las ventajas de rendimiento del operador bitwise desplazamiento a la derecha (Right shift) en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RendimientoDesplazamientoDerecha | |
{ | |
static void Main() | |
{ | |
System.Diagnostics.Stopwatch cronometro = new System.Diagnostics.Stopwatch(); | |
cronometro.Start(); | |
byte divisionConBitWise = 3 >> 2; | |
cronometro.Stop(); | |
Console.WriteLine("Tiempo transcurrido: {0}", cronometro.Elapsed.TotalMilliseconds); // 0.0005 (puede variar) | |
cronometro.Reset(); | |
cronometro.Start(); | |
byte divisionConMathPow = (byte)(3 / Math.Pow(2, 2)); | |
Console.WriteLine("Tiempo transcurrido: {0}", cronometro.Elapsed.TotalMilliseconds); // 0.0061 (puede variar) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment