Changes

Jump to navigation Jump to search
3,527 bytes added ,  12:04, 6 December 2010
Created page with "<p>This module offers utility methods, which can be used for testing and profiling the code. All functions are preceded by the <code>util:</code> prefix. </p> ==util:eval== <t..."
<p>This module offers utility methods, which can be used for testing and profiling the code. All functions are preceded by the <code>util:</code> prefix. </p>

==util:eval==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>util:eval</b>($expr as xs:string) as item()*</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Evaluates the argument at runtime.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function dynamically evaluates <code>$expr</code> as XQuery expression and returns the resulting items.<br />
</td>
</tr>
<tr>
<td>
<b>Examples</b>
</td>
<td>The expression <code>util:eval("1+3")</code> returns <code>4</code>.<br />
</td>
</tr>
</table>

==util:run==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>util:run</b>($input as xs:string) as item()*</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Opens the argument as file and evaluates it as at runtime.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function opens <code>$input</code> as file, evaluates it as XQuery expression, and returns the resulting items.<br />
</td>
</tr>
</table>

==util:mb==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>util:mb</b>($expr as item()) as xs:double</code>
<br />
<code>
<b>util:mb</b>($expr as item(), $cache as xs:boolean) as xs:double</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Measures the memory consumption for evaluating the argument.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function measures the amount of memory that is needed to evaluate <code>$expr</code>. If the value of <code>$cache</code> is <code>true()</code>, the result will be cached. The returned <code>xs:double</code> value represents the amount of memory in megabytes.<br />
</td>
</tr>
<tr>
<td>
<b>Examples</b>
</td>
<td>The expression <code>util:mb("1 to 100000")</code> might return <code>0</code>.<br />The expression <code>util:mb("1 to 100000", true())</code> might return <code>26.678</code>.<br />
</td>
</tr>
</table>

==util:ms==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>util:ms</b>($expr as item()) as xs:double</code>
<br />
<code>
<b>util:ms</b>($expr as item(), $cache as xs:boolean) as xs:double</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Measures the time needed for evaluating the argument.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function measures the time needed to evaluate <code>$expr</code>. If the value of <code>$cache</code> is <code>true()</code>, the result will be cached. The returned <code>xs:double</code> value represents the needed time in milliseconds.<br />
</td>
</tr>
<tr>
<td>
<b>Examples</b>
</td>
<td>The expression <code>util:ms("1 to 100000")</code> might return <code>25.69</code>.<br />The expression <code>util:ms("1 to 100000", true())</code> might return <code>208.12</code>.<br />
</td>
</tr>
</table>
Anonymous user

Navigation menu