Skip to content

Instantly share code, notes, and snippets.

@ArcticEcho
Last active August 29, 2015 14:02
Show Gist options
  • Save ArcticEcho/c1819b9a05e338fa403e to your computer and use it in GitHub Desktop.
Save ArcticEcho/c1819b9a05e338fa403e to your computer and use it in GitHub Desktop.
Updated M1 vs updated M2.
// 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