Function Repository Resource:

EchoPerformance

Source Notebook

Print the timing and memory used to evaluate an expression

Contributed by: Wolfram Staff

ResourceFunction["EchoPerformance"][expr]

prints the absolute number of seconds and memory in bytes used to evaluate expr and returns expr.

ResourceFunction["EchoPerformance"][expr,label]

prepends label to a printed expression.

Details and Options

ResourceFunction["EchoPerformance"][expr] uses Head[Unevaluated[expr]] as label.
ResourceFunction["EchoPerformance"] has the attribute HoldFirst.

Examples

Basic Examples (2) 

Evaluate an expression and print the time it took and the memory used:

In[1]:=
ResourceFunction["EchoPerformance"][Range[100]]
Out[1]=

Use a custom label to print performance data:

In[2]:=
ResourceFunction["EchoPerformance"][Range[100], "my label"]
Out[2]=

Properties and Relations (3) 

AbsoluteTiming gives the time it takes to evaluate an expression:

In[3]:=
AbsoluteTiming[Total[Range[123456789]]]
Out[3]=

MaxMemoryUsed gives the maximum number of bytes used in evaluating an expression:

In[4]:=
MaxMemoryUsed[Total[Range[123456789]]]
Out[4]=

EchoPerformance prints the same performance data:

In[5]:=
ResourceFunction["EchoPerformance"][Total[Range[123456789]]]
Out[5]=

Version History

  • 1.0.0 – 25 September 2020

Related Resources

License Information