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

# 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"
    }
  ]
}
```
