Contact Us 1-800-596-4880

time

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

Name Description

valueToMeasure

A function to pass to time.

Example

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

%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

{
  "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"
    }
  ]
}