Units & Dates

Measure Evaluation Timing

Measure the time taken by an evaluation.

In[1]:=
Click for copyable input
AbsoluteTiming[Total[Range[10000]]]
Out[1]=

Use RepeatedTiming to determine the average timing for an evaluation run repeatedly.

In[2]:=
Click for copyable input
RepeatedTiming[Total[Range[10000]]]
Out[2]=

Compare the average evaluation time of various methods of constructing arrays.

In[3]:=
Click for copyable input
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
In[4]:=
Click for copyable input
BarChart[timings, ChartLabels -> funs /. Function[head_[__]] :> head, PlotTheme -> "Marketing", ImageSize -> 500, ScalingFunctions -> "Log"]
Out[4]=

Related Examples

de es fr ja ko pt-br ru zh