prl.utils package¶
Submodules¶
prl.utils.loggers module¶
-
class
Logger[source]¶ Bases:
objectClass for logging scalar values to limited queues. Logged data send to each client is tracked by the Logger, so each client can ask for unseen data and recieve it.
-
add(key, value)[source]¶ Add a value to queue assigned to key value.
Parameters: - key (
str) – logged value name - value (
Number) – logged number
- key (
-
flush(consumer_id)[source]¶ Method used by clients to recieve only new unseed data from logger.
Parameters: consumer_id ( int) – value returned by register method.Return type: (typing.Dict[str, typing.List], typing.Dict[str, range], typing.Dict[str, typing.List]) Returns: dict with new data.
-
-
class
TimeLogger[source]¶ Bases:
prl.utils.loggers.LoggerStorage for measurements of function and methods exectuion time. Used by timeit function/decorator. Can be used to print summary of a time profiling or save all data to generate a plot how execution times are changing during the program execution.
prl.utils.misc module¶
prl.utils.utils module¶
-
timeit(func, profiled_function_name=None)[source]¶ Decorator for profiling execution time for the functions and methods. To measure time of a method or function you have to put @timeit in line nefore function, or wrap a function in the code:
@timeit def func(a, b, c=”1”):
passor in the code:
result = timeit(func, profiled_function_name=”Profiled function func”)(5,5)
To print results of measurment you have to print time_logger object from this package at the end of the program execution. When the name of the function can be ambiguous in the profiler data use profiled_function_name parameter.
Parameters: - func – function, which execution time we wan to measure
- profiled_function_name – user defined name for the wrapped function.
Returns: wrapped function