<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.elapsedTime.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.elapsedTime</api:function-name><api:suggest>xdmp.elapsedtime</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>elapsedtime</api:suggest><api:function-link mode="xquery" fullname="xdmp:elapsed-time">/apidoc/8.0/xdmp:elapsed-time.xml</api:function-link><api:function mode="javascript" name="elapsedTime" type="builtin" lib="xdmp" category="Extension" subcategory="MarkLogic Server" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.elapsedTime"><api:summary>
  Returns the elapsed time since the start of processing of this query.  Gives
  the same information as the <code xmlns="http://www.w3.org/1999/xhtml">elapsed-time</code> element of the
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:query-meters</code> output, but has less overhead than calling
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:query-meters</code>.
</api:summary><api:return>xs.dayTimeDuration</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">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
  <code>xdmp:estimate</code>, <code>xdmp:exists</code>, and lexicon calls
  (for example, <code>cts:element-values</code>).  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 <code>xdmp:estimate</code> in a <code>let</code>
  expression, you can add 0 to the output, which causes it to be included in
  the timings (something like <code>xdmp:estimate($query) + 0</code>).</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.count(fn.collection());
xdmp.elapsedTime();

=&gt; 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;

=&gt; [28,"PT0.00552S"]
</pre></api:example></api:function></api:function-page>