Loading TOC...

xdmp.elapsedTime

xdmp.elapsedTime() as xs.dayTimeDuration

Summary

Returns the elapsed time since the start of processing of this query. Gives the same information as the elapsed-time element of the xdmp:query-meters output, but has less overhead than calling xdmp:query-meters.

Usage Notes

Certain operations are run concurrently with the timing operations, and if those operations are not actually used in the query, they might not be included in the timings. This occurs for operations like xdmp:estimate, xdmp:exists, and lexicon calls (for example, cts:element-values). If you want to see the total timings that include calls that are not used, you can form some other expression with the results of the calls. For example, if you have an expression that calls xdmp:estimate in a let expression, you can add 0 to the output, which causes it to be included in the timings (something like xdmp:estimate($query) + 0).

Example

fn.count(fn.collection());
xdmp.elapsedTime();

=> PT0.006126S

If you want to return both the count and the time, you can do the following:

var res = [];
res.push(fn.count(fn.collection()));
res.push(xdmp.elapsedTime());
res;

=> [28,"PT0.00552S"]

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.