Difference between revisions of "Database Module"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | <p>This module | + | <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== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| width="90" | <b>Signatures</b> | | width="90" | <b>Signatures</b> | ||
− | |<code><b> | + | |<code><b>util:eval</b>($expr as xs:string) as item()*</code> |
|- | |- | ||
| <b>Summary</b> | | <b>Summary</b> | ||
− | | | + | | Evaluates the argument at runtime. |
|- | |- | ||
| <b>Rules</b> | | <b>Rules</b> | ||
− | | This function | + | | This function dynamically evaluates <code>$expr</code> as XQuery expression and returns the resulting items.<br /> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <b>Examples</b> | | <b>Examples</b> | ||
− | | The expression <code> | + | | The expression <code>util:eval("1+3")</code> returns <code>4</code>.<br /> |
− | |||
− | |||
− | |||
|} | |} | ||
− | == | + | ==util:run== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| width="90" | <b>Signatures</b> | | width="90" | <b>Signatures</b> | ||
− | |<code><b> | + | |<code><b>util:run</b>($input as xs:string) as item()*</code> |
|- | |- | ||
| <b>Summary</b> | | <b>Summary</b> | ||
− | | | + | | Opens the argument as file and evaluates it as at runtime. |
|- | |- | ||
| <b>Rules</b> | | <b>Rules</b> | ||
− | | This function opens | + | | This function opens <code>$input</code> as file, evaluates it as XQuery expression, and returns the resulting items.<br /> |
− | |||
− | |||
− | |||
|} | |} | ||
− | == | + | ==util:mb== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{| | {| | ||
|- | |- | ||
| width="90" | <b>Signatures</b> | | width="90" | <b>Signatures</b> | ||
− | |<code><b> | + | |<code><b>util:mb</b>($expr as item()) as xs:double</code> |
+ | |<code><b>util:mb</b>($expr as item(), $cache as xs:boolean) as xs:double</code> | ||
|- | |- | ||
| <b>Summary</b> | | <b>Summary</b> | ||
− | | | + | | Measures the memory consumption for evaluating the argument. |
|- | |- | ||
| <b>Rules</b> | | <b>Rules</b> | ||
− | | This function | + | | 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 /> |
|- | |- | ||
− | | <b> | + | | <b>Examples</b> |
− | |< | + | | 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 /> |
|} | |} | ||
+ | |||
+ | ==util:ms== | ||
− | |||
{| | {| | ||
|- | |- | ||
| width="90" | <b>Signatures</b> | | width="90" | <b>Signatures</b> | ||
− | |<code><b> | + | |<code><b>util:ms</b>($expr as item()) as xs:double</code> |
+ | |<code><b>util:ms</b>($expr as item(), $cache as xs:boolean) as xs:double</code> | ||
|- | |- | ||
| <b>Summary</b> | | <b>Summary</b> | ||
− | | | + | | Measures the time needed for evaluating the argument. |
|- | |- | ||
| <b>Rules</b> | | <b>Rules</b> | ||
− | | This function | + | | 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 /> |
|- | |- | ||
− | | <b> | + | | <b>Examples</b> |
− | |< | + | | 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 /> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
− | + | [[Category:XQuery]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[Category: |
Revision as of 16:35, 12 December 2010
This module offers utility methods, which can be used for testing and profiling the code. All functions are preceded by the util:
prefix.
Contents
util:eval
Signatures | util:eval($expr as xs:string) as item()*
|
Summary | Evaluates the argument at runtime. |
Rules | This function dynamically evaluates $expr as XQuery expression and returns the resulting items. |
Examples | The expression util:eval("1+3") returns 4 . |
util:run
Signatures | util:run($input as xs:string) as item()*
|
Summary | Opens the argument as file and evaluates it as at runtime. |
Rules | This function opens $input as file, evaluates it as XQuery expression, and returns the resulting items. |
util:mb
Signatures | util:mb($expr as item()) as xs:double
|
util:mb($expr as item(), $cache as xs:boolean) as xs:double
|
Summary | Measures the memory consumption for evaluating the argument. | |
Rules | This function measures the amount of memory that is needed to evaluate $expr . If the value of $cache is true() , the result will be cached. The returned xs:double value represents the amount of memory in megabytes. | |
Examples | The expression util:mb("1 to 100000") might return 0 .The expression util:mb("1 to 100000", true()) might return 26.678 . |
util:ms
Signatures | util:ms($expr as item()) as xs:double
|
util:ms($expr as item(), $cache as xs:boolean) as xs:double
|
Summary | Measures the time needed for evaluating the argument. | |
Rules | This function measures the time needed to evaluate $expr . If the value of $cache is true() , the result will be cached. The returned xs:double value represents the needed time in milliseconds. | |
Examples | The expression util:ms("1 to 100000") might return 25.69 .The expression util:ms("1 to 100000", true()) might return 208.12 . |