Changes

Jump to navigation Jump to search
145 bytes removed ,  18:37, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|prof:track|$expression as item()|item()*}}<br/pre>{{Func|prof:track|( $expression input as item()*, $options as map(*)?| := map { }) as item()*}}</pre>
|- valign="top"
| '''Summary'''
|Measures the execution time and memory consumption required for evaluating the specified {{Code|$expressioninput}} and returns a map with the results. The following {{Code|$options}} are available:
* {{Code|time}}: Include execution time in result as {{Code|xs:decimal}} (unit: milliseconds; default: true).
* {{Code|memory}}: Include memory consumption in result as {{Code|xs:integer}} (unit: bytes; default: false).
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
|
* Return a human-readable representation of the memory consumption caused by fetching an XML document. {{Function||fetch:doc}} is used, as <code>fn:doc</code> may already be evaluated at compilation time:
<syntaxhighlight pre lang="'xquery"'>
prof:track(fetch:doc('factbook.xml'))?memory
=> prof:human()
</syntaxhighlightpre>
* The function call <code>prof:track((1 to 1000000)[. mod 2 = 0], map { 'time': false() })</code> will return something similar to:
<syntaxhighlight pre lang="'xquery"'>
map {
"memory": 21548400,
"value": (2, 4, 6, 8, 10, ...)
}
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|prof:time|$expr as item()|item()*}}<br /pre>{{Func|prof:time|( $expr input as item(), $label as xs:string|? := ()) as item()*}}</pre>
|- valign="top"
| '''Summary'''
|Measures the time needed to evaluate {{Code|$exprinput}} and outputs a string to standard error or, if the GUI is used, to the Info View. An optional {{Code|$label}} may be specified to tag the profiling result. See {{Function||prof:track}} for further notes.
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|prof:memory|$expr as item()|item()*}}<br/pre>{{Func|prof:memory|( $expr input as item(), $label as xs:string|? := ()) as item()*}}</pre>
|- valign="top"
| '''Summary'''
|Measures the memory allocated by evaluating {{Code|$exprinput}} and outputs a string to standard error or, if the GUI is used, to the Info View. An optional {{Code|$label}} may be specified to tag the profiling result. See {{Function||prof:track}} for further notes.
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:current-ms||() as xs:integer}}<br /pre>
|- valign="top"
| '''Summary'''
|- valign="top"
| '''Properties'''
|In contrast to {{Code|fn:current-time()}}, the function is ''non-deterministicnondeterministic'' and returns different values every time it is called. Its evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:current-ns||() as xs:integer}}<br /pre>
|- valign="top"
| '''Summary'''
|- valign="top"
| '''Properties'''
|In contrast to {{Code|fn:current-time()}}, the function is ''non-deterministicnondeterministic'' and returns different values every time it is called. Its evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
| Measures the time of an expression:
<syntaxhighlight pre lang="'xquery"'>
let $ns1 := prof:current-ns()
return (
return $ms || ' ms'
)
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|prof:dump|$expr as item()*|empty-sequence()}}<br /pre>{{Func|prof:dump|( $expr input as item()*, $label as xs:string|? := ()) as empty-sequence()}}<br /pre>
|- valign="top"
| '''Summary'''
|Dumps a serialized representation of {{Code|$exprinput}} to {{Code|STDERR}}, optionally prefixed with {{Code|$label}}, and returns an empty sequence. If the GUI is used, the dumped result is shown in the [[Graphical User Interface#Visualizations|Info View]].
|- valign="top"
| '''Properties'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:variables||() as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
|Prints a list of all current local and global variable assignments to standard error or, if the GUI is used, to the Info View.<br />As every query is optimized before being evaluated, not all of the original variables may be visible in the output. Moreover, many variables of function calls will disappear because functions are inlined. Function inlining can be turned off by setting {{Option|INLINELIMIT}} to <code>0</code>.
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:type|( $expr as item()*|) as item()*}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|prof:gc||empty-sequence()}}<br/pre>{{Func|prof:gc|( $count as xs:integer| := ()) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:runtime|( $name of option as xs:string|) as xs:integer}}</pre>
|- valign="top"
| '''Summary'''
|Returns the value of the specified runtime {{Code|$option}}. The following options existare available:
* {{Code|max}}: Maximum memory that the Java virtual machine will attempt to use.
* {{Code|total}}: Total memory in the Java virtual machine (varies over time).
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:void|( $value input as item()*|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
|Swallows all items of Absorbs the specified {{Code|$valueinput}} and returns an empty sequence. This function is helpful if some (often nondeterministic or side-effecting) code needs to be evaluated and if the resulting value is irrelevantnot required.
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|- valign="top"
| '''Examples'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:sleep|( $ms as xs:integer|) as empty-sequence()}}<br /pre>
|- valign="top"
| '''Summary'''
|- valign="top"
| '''Properties'''
|The function is ''non-deterministicnondeterministic'': evaluation order will be preserved by the compiler.
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>prof:human|( $number as xs:integer|) as xs:string}}</pre>
|- valign="top"
| '''Summary'''
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu