xtd.core.stat.counter module¶
-
class
xtd.core.stat.counter.
BaseCounter
(p_name)[source]¶ Bases:
object
Abstract base counter
The almost-empty shell insure base methods are protected by a lock.
Parameters: p_name (str) – object name -
update
()[source]¶ Update object
Generally called by user just before visiting the object in order to gather “fresh” data
-
__dict__
= mappingproxy({'update': <function BaseCounter.update at 0x7f0b923bf7b8>, '__weakref__': <attribute '__weakref__' of 'BaseCounter' objects>, '__init__': <function BaseCounter.__init__ at 0x7f0b923bf6a8>, '_update_safe': <function BaseCounter._update_safe at 0x7f0b923bf8c8>, 'visit': <function BaseCounter.visit at 0x7f0b923bf730>, '__dict__': <attribute '__dict__' of 'BaseCounter' objects>, '_visit_safe': <function BaseCounter._visit_safe at 0x7f0b923bf840>, '__module__': 'xtd.core.stat.counter', '__doc__': ' Abstract base counter\n\n The almost-empty shell insure base methods are protected\n by a lock.\n\n Args:\n p_name (str): object name\n '})¶
-
__module__
= 'xtd.core.stat.counter'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
xtd.core.stat.counter.
Value
(p_name, p_value=None, p_type='i')[source]¶ Bases:
xtd.core.stat.counter.BaseCounter
Thread-safe numeric value holder
Parameters: Raises: Visitors
Value visitor must follow the following prototype:
function(p_name, p_value)
- p_name (str): name of visited Value
- p_value (numeric|str): internal value or
NaN
is unset
-
val
¶ (Property) internal value
If set to None, the current value is
undefined
Returns: current internal value, None if unset Return type: (numeric) Raises: TypeError
– affected value dosen’t match constructor type
-
incr
(p_val=1)[source]¶ Increments the current value
Parameters: p_val (numeric) – add p_val to current internal value Raises: TypeError
– given value dosen’t match constructor type
-
decr
(p_val=1)[source]¶ Decrements the current value
Parameters: p_val (numeric) – subtract p_val to current internal value Raises: TypeError
– given value dosen’t match constructor type
-
__module__
= 'xtd.core.stat.counter'¶
-
class
xtd.core.stat.counter.
Int32
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for signed 32 bits integer
-
TYPE
= 'i'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
Int64
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for signed 64 bits integer
-
TYPE
= 'l'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
UInt32
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for unsigned 32 bits integer
-
TYPE
= 'I'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
UInt64
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for unsigned 64 bits integer
-
TYPE
= 'L'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
Float
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for float
-
TYPE
= 'f'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
Double
(p_name, p_value=None)[source]¶ Bases:
xtd.core.stat.counter.Value
Value specialization for double
-
TYPE
= 'd'¶ multiprocessing.Value
type spec
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
Composed
(p_name)[source]¶ Bases:
xtd.core.stat.counter.BaseCounter
Manage a collection child counters
-
register
(p_counter)[source]¶ Register a child counter
Current object name is prepend to registered child name with the following format :
<parent-name>.<child-name>
Parameters: p_counter (BaseCounter) – child counter to add
-
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
TimedSample
(p_name, p_timeMs=10000, p_maxSamples=20000, p_type='i')[source]¶ Bases:
xtd.core.stat.counter.Composed
Holds the min, max and average value of collected items over a fixed period of time
When no items are available for the last
p_timeMs
, the 3 sub counters are undefined, thus, collected by visitors asNaN
.Parameters: -
__module__
= 'xtd.core.stat.counter'¶
-
-
class
xtd.core.stat.counter.
Perf
(p_name, p_timeMs=10000, p_maxSamples=20000)[source]¶ Bases:
xtd.core.stat.counter.TimedSample
Designed to monitor the min, max and average time of an event
At event start call
work_begin()
to store the current time. At event end, callwork_end()
to calculate the time detla and add it the base class samples that monitors the min max and average valuesThe time resolution is the microsecond (10^-6 second).
Note
Events beginnings and ends can’t be interleaved in the same thread.
-
__module__
= 'xtd.core.stat.counter'¶
-
work_begin
()[source]¶ Record begin time of an event
Raises: CounterError
– called twice from same thread with nowork_end()
between them
-
work_end
()[source]¶ Record end time of an event and push it into base class
Raises: CounterError
– called without callingwork_begin()
first from same thread
-
-
exception
xtd.core.stat.counter.
CounterError
(p_module, p_name, p_msg, *p_args, **p_kwds)[source]¶ Bases:
xtd.core.error.XtdError
Generic counter error class
Parameters: -
m_name
¶ str
name of counter that raised the error
-
__module__
= 'xtd.core.stat.counter'¶
-