Measure Evaluation Timing
Measure the time taken by an evaluation.
In[1]:=
AbsoluteTiming[Total[Range[10000]]]
Out[1]=
Use RepeatedTiming to determine the average timing for an evaluation run repeatedly.
In[2]:=
RepeatedTiming[Total[Range[10000]]]
Out[2]=
Compare the average evaluation time of various methods of constructing arrays.
In[3]:=
funs = {
Table[0, {i, #}, {j, #}] &,
Map[Map[0 &, Range[#]], Range[#]] &,
Scan[Scan[Sow[0], Range[#]], Range[#]] &,
ConstantArray[0, {#, #}] &,
Array[0 &, {#, #}] &,
Outer[0 &, Range[#], Range[#]] &
};
timings = First[ RepeatedTiming[#[100]]] & /@ funs;
show complete Wolfram Language input
Out[4]=