You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deferrable_functions_reference.rst
+27-2Lines changed: 27 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,20 @@ Deferrable Functions Reference
7
7
*Deferrable functions* are the functions whose execution may be postponed to a later time after they are called.
8
8
The key characteristic of these functions is that they store their arguments when they are called, and the execution itself does not occur until the function is evaluated either explicitly or implicitly.
9
9
10
+
ReFrame provides an ample set of deferrable utilities and it also allows users to write their own deferrable functions when needed.
11
+
Please refer to ":doc:`deferrables`" for a hands-on explanation on how deferrable functions work and how to create custom deferrable functions.
12
+
13
+
10
14
Explicit evaluation of deferrable functions
11
15
-------------------------------------------
12
16
13
17
Deferrable functions may be evaluated at any time by calling :func:`evaluate` on their return value or by passing the deferred function itself to the :func:`~reframe.utility.sanity.evaluate()` free function.
18
+
These :func:`evaluate` functions take an optional :class:`bool` argument ``cache``, which can be used to cache the evaluation of the deferrable function.
19
+
Hence, if caching is enabled on a given deferrable function, any subsequent calls to :func:`evaluate` will simply return the previously cached results.
20
+
21
+
.. versionchanged:: 3.8.0
22
+
Support of cached evaluation is added.
23
+
14
24
15
25
Implicit evaluation of deferrable functions
16
26
-------------------------------------------
@@ -48,9 +58,24 @@ Currently ReFrame provides three broad categories of deferrable functions:
48
58
They include, but are not limited to, functions to iterate over regex matches in a file, extracting and converting values from regex matches, computing statistical information on series of data etc.
49
59
50
60
51
-
Users can write their own deferrable functions as well.
52
-
The page ":doc:`deferrables`" explains in detail how deferrable functions work and how users can write their own.
61
+
.. _deferrable-performance-functions:
62
+
63
+
64
+
--------------------------------
65
+
Deferrable performance functions
66
+
--------------------------------
67
+
68
+
.. versionadded:: 3.8.0
69
+
70
+
Deferrable performance functions are a special type of deferrable functions which are intended for measuring a given quantity.
71
+
Therefore, this kind of deferrable functions have an associated unit that can be used to interpret the return values from these functions.
72
+
The unit of a deferrable performance function can be accessed through the public member :attr:`unit`.
73
+
Regular deferrable functions can be promoted to deferrable performance functions using the :func:`~reframe.utility.sanity.make_performance_function` utility.
74
+
Also, this utility allows to create performance functions directly from any callable.
Decorate a member function as a performance function of the test.
328
+
329
+
This decorator converts the decorated method into a performance deferrable function (see ":ref:`deferrable-performance-functions`" for more details) whose evaluation is deferred to the performance stage of the regression test.
330
+
The decorated function must take a single argument without a default value (i.e. ``self``) and any number of arguments with default values.
331
+
A test may decorate multiple member functions as performance functions, where each of the decorated functions must be provided with the units of the performance quantitites to be extracted from the test.
332
+
These performance units must be of type :class:`str`.
333
+
Any performance function may be overridden in a derived class and multiple bases may define their own performance functions.
334
+
In the event of a name conflict, the derived class will follow Python's `MRO <https://docs.python.org/3/library/stdtypes.html#class.__mro__>`_ to choose the appropriate performance function.
335
+
However, defining more than one performance function with the same name in the same class is disallowed.
336
+
337
+
The full set of performance functions of a regression test is stored under :attr:`~reframe.core.pipeline.RegressionTest.perf_variables` as key-value pairs, where, by default, the key is the name of the decorated member function, and the value is the deferred performance function itself.
338
+
Optionally, the key under which a performance function is stored in :attr:`~reframe.core.pipeline.RegressionTest.perf_variables` can be customised by passing the desired key as the ``perf_key`` argument to this decorator.
0 commit comments