jina.logging.profile¶
-
jina.logging.profile.
used_memory
(unit=1073741824)[source]¶ Get the memory usage of the current process.
- Parameters
unit (
int
) – Unit of the memory, default in Gigabytes.- Return type
float
- Returns
Memory usage of the current process.
-
jina.logging.profile.
used_memory_readable
()[source]¶ Get the memory usage of the current process in a human-readable format.
- Return type
str
- Returns
Memory usage of the current process.
-
jina.logging.profile.
profiling
(func)[source]¶ Create the Decorator to mark a function for profiling. The time and memory usage will be recorded and printed.
Example: .. highlight:: python .. code-block:: python
@profiling def foo():
print(1)
- Parameters
func – function to be profiled
- Returns
arguments wrapper
-
class
jina.logging.profile.
TimeContext
(task_name, logger=None)[source]¶ Bases:
object
Timing a code snippet with a context manager.
Create the context manager to timing a code snippet.
- Parameters
task_name (
str
) – The context/message.logger (JinaLogger) – Use existing logger or use naive
print()
.
Example: .. highlight:: python .. code-block:: python
- with TimeContext(‘loop’):
do_busy()
-
time_attrs
= ['years', 'months', 'days', 'hours', 'minutes', 'seconds']¶
-
class
jina.logging.profile.
ProgressBar
(bar_len=20, task_name='', batch_unit='requests', logger=None)[source]¶ Bases:
jina.logging.profile.TimeContext
A simple progress bar.
- Example:
with ProgressBar('loop'): do_busy()
Create the ProgressBar.
- Parameters
bar_len (
int
) – Total length of the bar.task_name (
str
) – The name of the task, will be displayed in front of the bar.batch_unit (
str
) – Unit of batchlogger – Jina logger