Contact Free trial Login

duration

duration(() -> T): DurationMeasurement<T>

Executes the function and returns an object with the taken time in milliseconds with the result of the function.

Parameters

Name Description

valueToMeasure

A function to pass to duration.

Example

This example passes a wait function (defined in the header), which returns the result in a DurationMeasurement object.

Source

%dw 2.0
output application/json
fun myFunction() = dw::Runtime::wait("My result",100)
---
dw::util::Timer::duration(() -> myFunction())

Output

{
  "time": 101,
  "result": "My result"
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub