Function Repository Resource:

EvaluationTiming

Source Notebook

Get a full timing report for functions evaluated during an evaluation

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["EvaluationTiming"][eval]

captures timing information for functions evaluated in eval.

ResourceFunction["EvaluationTiming"][eval,contexts]

captures timing information for functions in contexts.

Examples

Basic Examples (3) 

Get timing data for functions used in an evaluation:

In[1]:=
f[x_] := (Pause[.25]; g[x]);
g[x_] := (Pause[.5]; x + 1);
data = ResourceFunction["EvaluationTiming"][f /@ Range[5]]
Out[3]=

View the timing data as a Dataset:

In[4]:=
Dataset[data]
Out[4]=

Get the evaluation result:

In[5]:=
data["Result"]
Out[5]=

Scope (9) 

Track the timing of functions in specific contexts:

In[6]:=
data = ResourceFunction["EvaluationTiming"][
  CloudDeploy[FormFunction[{"x" -> "Integer"}, #x! &]],
  "CloudObject`" | "CURLLink`" | "URLUtilities`" ~~ ___
  ]
Out[6]=

Get the evaluation result:

In[7]:=
data["Result"]
Out[7]=

View the timing data (function names are color-coded by context):

In[8]:=
data["Summary"]
Out[8]=

View a BarChart:

In[9]:=
BarChart[data, ScalingFunctions -> "Log"]
Out[9]=

View a PieChart:

In[10]:=
PieChart[data]
Out[10]=

View the top 5 functions that used the most time:

In[11]:=
data[{"Summary", 5}]
Out[11]=

Use a different key for sorting:

In[12]:=
data[{"Summary", 5, "Total"}]
Out[12]=

View a list of available properties:

In[13]:=
data["Properties"]
Out[13]=

Get the full data:

In[14]:=
data["ProfilingData"]
Out[14]=

Possible Issues (1) 

Without explicitly giving a context pattern, only functions in the current $Context will be tracked:

In[15]:=
MyContext`wait[] := Pause[1];
g[x_] := 2 x;
f[x_] := (MyContext`wait[]; g[x + 1]);
ResourceFunction["EvaluationTiming"][f[5]]["Summary"]
Out[9]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 12 October 2018

Related Resources

License Information