Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.