%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())
]
}
Dataweave
time
time(() -> 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 |
---|---|
|
A function to pass to |
Example
This example passes wait
and sum
functions (defined in the
header), which return their results in TimeMeasurement
objects.
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" } ] }
XML