class_docstr: Timing a code snippet with a context manager.
class_docstr_tok: ["Timing","a","code","snippet","with","a","context","manager","."]
docstr: Create the context manager to timing a code snippet.
  
  :param task_name: The context/message.
  :param logger: Use existing logger or use naive :func:`print`.
  
  Example:
  .. highlight:: python
  .. code-block:: python
  
      with TimeContext('loop'):
          do_busy()
docstr_tok: ["Create","the","context","manager","to","timing","a","code","snippet",".",":","param","task_name",":","The","context\/message",".",":","param","logger",":","Use","existing","logger","or","use","naive",":","func",":","`","print","`",".","Example",":","..","highlight",":",":","python","..","code-block",":",":","python","with","TimeContext","(","'loop","'",")",":","do_busy","(",")"]
code: def __init__(self, task_name: str, logger: "JinaLogger" = None):
      """
      Create the context manager to timing a code snippet.
  
      :param task_name: The context/message.
      :param logger: Use existing logger or use naive :func:`print`.
  
      Example:
      .. highlight:: python
      .. code-block:: python
  
          with TimeContext('loop'):
              do_busy()
  
      """
      self.task_name = task_name
      self._logger = logger
      self.duration = 0
  
imports: import time
  import typing
  from functools import wraps
  from typing import Optional, Union, Callable
  from jina.constants import __windows__
  from jina.helper import get_readable_size, get_readable_time, colored, get_rich_console
  from rich.progress import Progress, Task, BarColumn, TimeRemainingColumn, SpinnerColumn, TimeElapsedColumn, TextColumn, ProgressColumn, TaskID
  from rich.text import Text
  from rich.table import Column
  from rich.console import Console
label_desc: Use image node_id 1 to create a new TimeContext object  with example: obj = TimeContext(task_name, logger)