两者是3:2的消耗比例
const int NUM = 10000;
int[,] vec = new int[NUM, NUM];
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < NUM; i++)
{
for (int j = 0; j < NUM; j++)
{
var a = vec[i, j];
}
}
//317ms
Console.WriteLine(sw.ElapsedMilliseconds);
int[][] vecarr = new int[NUM][];
for (int i = 0; i < vecarr.Length; i++)
{
vecarr[i] = new int[NUM];
}
sw = Stopwatch.StartNew();
for (int i = 0; i < NUM; i++)
{
for (int j = 0; j < NUM; j++)
{
var a = vecarr[i][ j];
}
}
//174ms
Console.WriteLine(sw.ElapsedMilliseconds);