---
schema_version: "1"
id: 4fe077a8e3aac265ad70c9ce957fd9b43c7d8647528c1e0488b40d51105a35a6
title: time
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-timer-functions-time.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-timer-functions-time
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3abbf919fdaf27985899677e54b609caf8475b7eb81f9531dd3333c5d6923ac8
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# time

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## time<T>(valueToMeasure: () -> T): TimeMeasurement<T>

Executes the input function and returns a `TimeMeasurement` object that contains the start and end
time for the execution of that function, as well the result of the function.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>valueToMeasure</code></p></td><td><p>A function to pass to <code>time</code>.</p></td></tr></tbody></table>

### Example

This example passes `wait` and `sum` functions (defined in the header), which return their results
in `TimeMeasurement` objects.

```Dataweave
%dw 2.0
output application/json
fun myFunction() = dw::Runtime::wait("My result",100)
fun myFunction2() = sum([1,2,3,4])
---
{ testing: [
    dw::util::Timer::time(() -> myFunction()),
    dw::util::Timer::time(() -> myFunction2())
  ]
}
```

#### Output

```XML
{
  "testing": [
    {
      "start": "2018-10-05T19:23:01.49Z",
      "result": "My result",
      "end": "2018-10-05T19:23:01.591Z"
    },
    {
      "start": "2018-10-05T19:23:01.591Z",
      "result": 10,
      "end": "2018-10-05T19:23:01.591Z"
    }
  ]
}
```
