Three methods("Sum", "Total@Table" and "Do") have been used to do the same work. The "Sum" and "Total@Table" function becomes extremely slow at num=250 (This number may depend on Computer's condition. My Laptop is MacBook Pro 2013 Late with 8G DRAM). I hope to understand the reason and how to AVOID it
timelist = ConstantArray[0, {3, 20}];
Do[
num = nn*1 + 239;
mat = RandomReal[{0, 1}, {num, num, 2, 2, 2}];
timelist[[1, nn]] =
Timing[r1 = Sum[mat[[l, 1]] l, {l, 1, num}];][[1]];
timelist[[2, nn]] =
Timing[r2 = Total@Table[mat[[l, 1]] l, {l, 1, num}];][[1]];
timelist[[3, nn]] = Timing[r3 = ConstantArray[0, Dimensions[r2]];
Do[r3 = r3 + mat[[l, 1]] l, {l, 1, num}];][[1]];
(*SameQ[r1,r2,r3]*)
, {nn, 1, 20}]
ListLinePlot[timelist, DataRange -> {240, 260},
PlotLegends -> {"Sum", "Total@Table", "Do"},
AxesLabel -> {"num", "Seconds"}, ScalingFunctions -> "Log"]