---
title: "EchoTiming"
language: "en"
type: "Symbol"
summary: "EchoTiming[expr] evaluates expr, prints the time in seconds used and returns the result of the evaluation. EchoTiming[expr, label] prints the timing, prepending label."
keywords: 
- echo
- echo timing
- benchmark
- performance analysis
- profiling
- debug
- debugging
- report
canonical_url: "https://reference.wolfram.com/language/ref/EchoTiming.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Tuning & Debugging"
    link: "https://reference.wolfram.com/language/guide/TuningAndDebugging.en.md"
  - 
    title: "Time Measurement & Optimization"
    link: "https://reference.wolfram.com/language/guide/TimeMeasurementAndOptimization.en.md"
  - 
    title: "Robustness & Error Handling"
    link: "https://reference.wolfram.com/language/guide/RobustnessAndErrorHandling.en.md"
related_functions: 
  - 
    title: "Echo"
    link: "https://reference.wolfram.com/language/ref/Echo.en.md"
  - 
    title: "EchoEvaluation"
    link: "https://reference.wolfram.com/language/ref/EchoEvaluation.en.md"
  - 
    title: "QuietEcho"
    link: "https://reference.wolfram.com/language/ref/QuietEcho.en.md"
  - 
    title: "EchoFunction"
    link: "https://reference.wolfram.com/language/ref/EchoFunction.en.md"
  - 
    title: "EchoLabel"
    link: "https://reference.wolfram.com/language/ref/EchoLabel.en.md"
  - 
    title: "Timing"
    link: "https://reference.wolfram.com/language/ref/Timing.en.md"
  - 
    title: "AbsoluteTiming"
    link: "https://reference.wolfram.com/language/ref/AbsoluteTiming.en.md"
  - 
    title: "RepeatedTiming"
    link: "https://reference.wolfram.com/language/ref/RepeatedTiming.en.md"
---
[EXPERIMENTAL]

# EchoTiming

EchoTiming[expr] evaluates expr, prints the time in seconds used and returns the result of the evaluation.

EchoTiming[expr, label] prints the timing, prepending label.

## Details and Options

* ``EchoTiming`` is a variant of ``Echo`` that reports the absolute timing of an evaluation.

* ``EchoTiming`` has attribute ``HoldFirst``.

* The following options can be given:

[`Method`](https://reference.wolfram.com/language/ref/Method.en.md) 	[`AbsoluteTiming`](https://reference.wolfram.com/language/ref/AbsoluteTiming.en.md)	method to use to time the evaluation

* Possible settings for the ``Method`` option include:

|                |                                                         |
| -------------- | ------------------------------------------------------- |
| Timing         | print the CPU time spent in the Wolfram Language kernel |
| AbsoluteTiming | print the real wall clock time that has elapsed         |
| RepeatedTiming | print the average timing of several evaluations         |

* The value of ``Method`` should be a function of one argument that returns a list ``{timing, result}``. ``EchoTiming`` will print ``timing`` and return ``result``.

---

## Examples (11)

### Basic Examples (2)

Print the timing of an intermediate computation:

```wl
In[1]:= Length[EchoTiming[{Pause[0.5], Pause[0.3], Pause[0.2]}]]

⌚ 1.00381

Out[1]= 3

In[2]:= Length[EchoTiming[{Pause[0.5], Pause[0.3], Pause[0.2]}, Method -> Timing]]

⌚ 0.122255

Out[2]= 3
```

---

Print the timing with a label:

```wl
In[1]:= expr1;EchoTiming[Total[Range[10 ^ 9]], "total:"];expr2

⌚ "total:"  1.97482

Out[1]= expr2
```

### Scope (1)

Time the construction of all 8-letter subsets in the English alphabet:

```wl
In[1]:= Length[EchoTiming[Subsets[Alphabet[], {8}]]]

⌚ 0.158876

Out[1]= 1562275
```

### Options (2)

#### Method (2)

By default, ``EchoTiming`` uses ``AbsoluteTiming`` to report timings:

```wl
In[1]:= Length[EchoTiming[{Pause[0.5], Pause[0.3], Pause[0.2]}]]

⌚ 1.00282

Out[1]= 3
```

Use ``Timing`` to report only time spent in the Wolfram Language kernel:

```wl
In[2]:= Length[EchoTiming[{Pause[0.5], Pause[0.3], Pause[0.2]}, Method -> Timing]]

⌚ 0.016015

Out[2]= 3
```

---

Define a custom timing function, which must have have a holding attribute like ``HoldFirst`` :

```wl
In[1]:=
SetAttributes[myTiming, HoldFirst];
myTiming[expr_] := AbsoluteTiming[TimeConstrained[expr, 3]]
```

Use it as the timing ``Method`` :

```wl
In[2]:= EchoTiming[Pause[5];2 + 2, Method -> myTiming]

⌚ 3.0012

Out[2]= $Aborted
```

### Applications (2)

Time ``EntityValue`` calls:

```wl
In[1]:= GeoGraphics[EchoTiming@EntityValue[Entity["GeographicRegion", "Africa"], "Polygon"]]

⌚ 7.55033

Out[1]= [image]
```

---

Set ``\$Pre`` to ``EchoTiming`` to print the timing of all computations:

```wl
In[1]:= $Pre = EchoTiming

Out[1]= EchoTiming
```

The timing gets automatically printed:

```wl
In[2]:= Pause[1];2 + 2

⌚ 1.00064

Out[2]= 4
```

Unset ``\$Pre`` :

```wl
In[3]:= $Pre=.

⌚ 0.
```

### Properties & Relations (3)

With ``Method -> RepeatedTiming``, only the result of the first evaluation is returned:

```wl
In[1]:= x = 0;EchoTiming[x++, Method -> RepeatedTiming]

⌚ 1.4452075958251954`*^-7

Out[1]= 8388607
```

---

``EchoTiming`` can be used to print the timing of intermediate computations without affecting the overall computation:

```wl
In[1]:= x = 1;EchoTiming[Pause[x++]];x

⌚ 1.00082

Out[1]= 2
```

``Echo`` can also be used to print the timing, but at the cost of doing the computation twice, which may not be desirable:

```wl
In[2]:= x = 1;Echo[Unevaluated[Pause[x++]], "timing:", AbsoluteTiming];x

>> "timing:"  {1.00025, Null}

Out[2]= 3
```

---

``EchoTiming`` is disabled inside ``QuietEcho`` :

```wl
In[1]:= QuietEcho[EchoTiming[1 + 1]]

Out[1]= 2
```

### Neat Examples (1)

Find factorizations of numbers of the form $2^n-1$, printing intermediate results and their timings:

```wl
In[1]:= EchoTiming[Table[Echo@EchoTiming@FactorInteger[2 ^ n - 1], {n, 100, 500, 100}], "Total:"]

⌚ 0.001037

>> {{3, 1}, {5, 3}, {11, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {601, 1}, {1801, 1}, {4051, 1}, {8101, 1}, {268501, 1}}

⌚ 0.017554

>> {{3, 1}, {5, 3}, {11, 1}, {17, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {401, 1}, {601, 1}, {1801, 1}, {4051, 1}, {8101, 1}, {61681, 1}, {268501, 1}, {340801, 1}, {2787601, 1}, {3173389601, 1}}

⌚ 0.016168

>> {{3, 2}, {5, 3}, {7, 1}, {11, 1}, {13, 1}, {31, 1}, {41, 1}, {61, 1}, {101, 1}, {151, 1}, {251, 1}, {331, 1}, {601, 1}, {1201, 1}, {1321, 1}, {1801, 1}, {4051, 1}, {8101, 1}, {63901, 1}, {100801, 1}, {268501, 1}, {10567201, 1}, {13334701, 1}, {1182468601, 1}, {1133836730401, 1}}

⌚ 0.034751

>> {{3, 1}, {5, 3}, {11, 1}, {17, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {257, 1}, {401, 1}, {601, 1}, {1601, 1}, {1801, 1}, {4051, 1}, {8101, 1}, {25601, 1}, {61681, 1}, {268501, 1}, {340801, 1}, {2787601, 1}, {82471201, 1}, {3173389601, 1}, {4278255361, 1}, {432363203127002885506543172618401, 1}}

⌚ 3.32107

>> {{3, 1}, {5, 4}, {11, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {601, 1}, {1801, 1}, {4051, 1}, {7001, 1}, {8101, 1}, {28001, 1}, {96001, 1}, {268501, 1}, {3775501, 1}, {229668251, 1}, {269089806001, 1}, {4710883168879506001, 1}, {47970133603445383501, 1}, {94291866932171243501, 1}, {5519485418336288303251, 1}}

⌚ "Total:"  3.61244

Out[1]= {{{3, 1}, {5, 3}, {11, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {601, 1}, {1801, 1}, {4051, 1}, {8101, 1}, {268501, 1}}, {{3, 1}, {5, 3}, {11, 1}, {17, 1}, {31, 1}, {41, 1}, {101, 1}, {251, 1}, {401, 1}, {601, 1}, {1801, 1}, {4051, 1}, {8101, 1},  ... 01, 1}, {1801, 1}, {4051, 1}, {7001, 1}, {8101, 1}, {28001, 1}, {96001, 1}, {268501, 1}, {3775501, 1}, {229668251, 1}, {269089806001, 1}, {4710883168879506001, 1}, {47970133603445383501, 1}, {94291866932171243501, 1}, {5519485418336288303251, 1}}}
```

## See Also

* [`Echo`](https://reference.wolfram.com/language/ref/Echo.en.md)
* [`EchoEvaluation`](https://reference.wolfram.com/language/ref/EchoEvaluation.en.md)
* [`QuietEcho`](https://reference.wolfram.com/language/ref/QuietEcho.en.md)
* [`EchoFunction`](https://reference.wolfram.com/language/ref/EchoFunction.en.md)
* [`EchoLabel`](https://reference.wolfram.com/language/ref/EchoLabel.en.md)
* [`Timing`](https://reference.wolfram.com/language/ref/Timing.en.md)
* [`AbsoluteTiming`](https://reference.wolfram.com/language/ref/AbsoluteTiming.en.md)
* [`RepeatedTiming`](https://reference.wolfram.com/language/ref/RepeatedTiming.en.md)

## Related Guides

* [Tuning & Debugging](https://reference.wolfram.com/language/guide/TuningAndDebugging.en.md)
* [Time Measurement & Optimization](https://reference.wolfram.com/language/guide/TimeMeasurementAndOptimization.en.md)
* [Robustness & Error Handling](https://reference.wolfram.com/language/guide/RobustnessAndErrorHandling.en.md)

## History

* [Introduced in 2020 (12.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn122.en.md)