Changes

Jump to navigation Jump to search
598 bytes added ,  14:19, 20 July 2022
no edit summary
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:track|$expression as item()|item()*}}<br/>{{Func|prof:track|$expression as item(), $options as map(*)?|item()*}}
|-valign="top"
| '''Summary'''
|Measures the execution time and memory consumption required for evaluating the specified {{Code|$expression}} and returns a map with the results. The following {{Code|$options}} are available:
* If a value has a compact internal representation, memory consumption will be very low, even if the serialized result may consume much more memory.
* Please note that memory profiling is only approximative, so it can be quite misleading. If the memory option is enabled, main-memory will be garbage-collected before and after evaluation to improve the quality of the measurement.
|-valign="top"
| '''Properties'''
|The function is ''non-deterministic'': evaluation order will be preserved by the compiler.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:time|$expr as item()|item()*}}<br />{{Func|prof:time|$expr as item(), $label as xs:string|item()*}}
|-valign="top"
| '''Summary'''
|Measures the time needed to evaluate {{Code|$expr}} 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-deterministic'': evaluation order will be preserved by the compiler.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:memory|$expr as item()|item()*}}<br/>{{Func|prof:memory|$expr as item(), $label as xs:string|item()*}}
|-valign="top"
| '''Summary'''
|Measures the memory allocated by evaluating {{Code|$expr}} 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-deterministic'': evaluation order will be preserved by the compiler.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:current-ms||xs:integer}}<br />
|-valign="top"
| '''Summary'''
|Returns the number of milliseconds passed since 1970/01/01 UTC. The granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.
|-valign="top"
| '''Properties'''
|In contrast to {{Code|fn:current-time()}}, the function is ''non-deterministic'' 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' | '''Signatures'''
|{{Func|prof:current-ns||xs:integer}}<br />
|-valign="top"
| '''Summary'''
|Returns the current value of the most precise available system timer in nanoseconds.
|-valign="top"
| '''Properties'''
|In contrast to {{Code|fn:current-time()}}, the function is ''non-deterministic'' 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:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:dump|$expr as item()*|empty-sequence()}}<br />{{Func|prof:dump|$expr as item()*, $label as xs:string|empty-sequence()}}<br />
|-valign="top"
| '''Summary'''
|Dumps a serialized representation of {{Code|$expr}} 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'''
|In contrast to {{Code|fn:trace()}}, the consumed expression will not be passed on.
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:variables||empty-sequence()}}
|-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-deterministic'': evaluation order will be preserved by the compiler.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:type|$expr as item()*|item()*}}
|-valign="top"
| '''Summary'''
|Similar to {{Code|fn:trace($expr, $msg)}}, but instead of a user-defined message, it emits the compile-time type and estimated result size of its argument.
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:gc||empty-sequence()}}<br/>{{Func|prof:gc|$count as xs:integer|empty-sequence()}}
|-valign="top"
| '''Summary'''
|Enforces Java garbage collection. If no {{Code|$count}} is supplied, garbage will be collected once. Please note that this function should only be used for debugging purposes; in productive code, it is best to trust the garbage collecting strategies of Java.
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:runtime|$name of xs:string|xs:integer}}
|-valign="top"
| '''Summary'''
|Returns the value of the specified runtime {{Code|$option}}. The following options exist:
* {{Code|used}}: Currently used memory (varies over time, will shrink after garbage collection).
* {{Code|processors}}: number of processors available to the Java virtual machine.
|-valign="top"
|{{Code|option}}
|The specified option is unknown.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:void|$value as item()*|empty-sequence()}}
|-valign="top"
| '''Summary'''
|Swallows all items of the specified {{Code|$value}} and returns an empty sequence. This function is helpful if some code needs to be evaluated and if the actual result is irrelevant.
|-valign="top"
| '''Properties'''
|The function is ''non-deterministic'': evaluation order will be preserved by the compiler.
|-valign="top"
| '''Examples'''
|
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:sleep|$ms as xs:integer|empty-sequence()}}<br />
|-valign="top"
| '''Summary'''
|Sleeps for the specified number of milliseconds.
|-valign="top"
| '''Properties'''
|The function is ''non-deterministic'': evaluation order will be preserved by the compiler.
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|prof:human|$number as xs:integer|xs:string}}
|-valign="top"
| '''Summary'''
|Returns a human-readable representation of the specified {{Code|$number}}.
|-valign="top"
| '''Example'''
|
! width="110"|Code
|Description
|-valign="top"
|{{Code|option}}
|The specified option is unknown.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu