Last active
August 29, 2015 14:02
-
-
Save ArcticEcho/c1819b9a05e338fa403e to your computer and use it in GitHub Desktop.
Updated M1 vs updated M2.
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
// M1 is 108% faster than M2. | |
public static unsafe void TestMethod1() | |
{ | |
float* samples = stackalloc float[12500]; | |
for (var i = 0; i < 4000; i++) | |
{ | |
for (var ii = 0; ii < 12500; ii++) | |
{ | |
samples[ii] = 32768; | |
} | |
} | |
} | |
public static unsafe void TestMethod2() | |
{ | |
float[] samples = new float[12500]; | |
fixed (float* prt = samples) | |
{ | |
for (var i = 0; i < 4000; i++) | |
{ | |
for (var ii = 0; ii < 12500; ii++) | |
{ | |
prt[ii] = 32768; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment