class_docstr: A profiler for dask execution at the scheduler cache level.
  
  Records the following information for each task:
      1. Key
      2. Task
      3. Size metric
      4. Cache entry time in seconds since the epoch
      5. Cache exit time in seconds since the epoch
  
  Examples
  --------
  
  >>> from operator import add, mul
  >>> from dask.threaded import get
  >>> from dask.diagnostics import CacheProfiler
  >>> dsk = {'x': 1, 'y': (add, 'x', 10), 'z': (mul, 'y', 2)}
  >>> with CacheProfiler() as prof:
  ...     get(dsk, 'z')
  22
  
  >>> prof.results    # doctest: +SKIP
  [CacheData(key='y', task=(add, 'x', 10), metric=1, cache_time=..., free_time=...),
   CacheData(key='z', task=(mul, 'y', 2), metric=1, cache_time=..., free_time=...)]
  
  The default is to count each task (``metric`` is 1 for all tasks). Other
  functions may used as a metric instead through the ``metric`` keyword. For
  example, the ``nbytes`` function found in ``cachey`` can be used to measure
  the number of bytes in the cache.
  
  >>> from cachey import nbytes                   # doctest: +SKIP
  >>> with CacheProfiler(metric=nbytes) as prof:  # doctest: +SKIP
  ...     get(dsk, 'z')
  22
  
  The profiling results can be visualized in a bokeh plot using the
  ``visualize`` method. Note that this requires bokeh to be installed.
  
  >>> prof.visualize() # doctest: +SKIP
  
  You can activate the profiler globally
  
  >>> prof.register()
  
  If you use the profiler globally you will need to clear out old results
  manually.
  
  >>> prof.clear()
  >>> prof.unregister()
class_docstr_tok: ["A","profiler","for","dask","execution","at","the","scheduler","cache","level",".","Records","the","following","information","for","each","task",":","1",".","Key","2",".","Task","3",".","Size","metric","4",".","Cache","entry","time","in","seconds","since","the","epoch","5",".","Cache","exit","time","in","seconds","since","the","epoch","Examples","--","--","--","--",">",">",">","from","operator","import","add",",","mul",">",">",">","from","dask.threaded","import","get",">",">",">","from","dask.diagnostics","import","CacheProfiler",">",">",">","dsk","=","{","'","x","'",":","1",",","'","y","'",":","(","add",",","'","x","'",",","10",")",",","'","z","'",":","(","mul",",","'","y","'",",","2",")","}",">",">",">","with","CacheProfiler","(",")","as","prof",":","...","get","(","dsk",",","'","z","'",")","22",">",">",">","prof.results","#","doctest",":","+SKIP","[","CacheData","(","key=","'","y","'",",","task=","(","add",",","'","x","'",",","10",")",",","metric=1",",","cache_time=","...",",","free_time=","...",")",",","CacheData","(","key=","'","z","'",",","task=","(","mul",",","'","y","'",",","2",")",",","metric=1",",","cache_time=","...",",","free_time=","...",")","]","The","default","is","to","count","each","task","(","``","metric","``","is","1","for","all","tasks",")",".","Other","functions","may","used","as","a","metric","instead","through","the","``","metric","``","keyword",".","For","example",",","the","``","nbytes","``","function","found","in","``","cachey","``","can","be","used","to","measure","the","number","of","bytes","in","the","cache",".",">",">",">","from","cachey","import","nbytes","#","doctest",":","+SKIP",">",">",">","with","CacheProfiler","(","metric=nbytes",")","as","prof",":","#","doctest",":","+SKIP","...","get","(","dsk",",","'","z","'",")","22","The","profiling","results","can","be","visualized","in","a","bokeh","plot","using","the","``","visualize","``","method",".","Note","that","this","requires","bokeh","to","be","installed",".",">",">",">","prof.visualize","(",")","#","doctest",":","+SKIP","You","can","activate","the","profiler","globally",">",">",">","prof.register","(",")","If","you","use","the","profiler","globally","you","will","need","to","clear","out","old","results","manually",".",">",">",">","prof.clear","(",")",">",">",">","prof.unregister","(",")"]
docstr: Clear out old results from profiler
docstr_tok: ["Clear","out","old","results","from","profiler"]
code: def clear(self):
      """Clear out old results from profiler"""
      self.results = []
      self._cache = {}
      self._dsk = {}
      self.start_time = None
      self.end_time = None
  
imports: from __future__ import annotations
  from collections import namedtuple
  from itertools import starmap
  from multiprocessing import Pipe, Process, current_process
  from time import sleep
  from timeit import default_timer
  from dask.callbacks import Callback
  from dask.utils import import_required
label_desc: Use image node_id 9 for calling the CacheProfiler obj's underlying member method code with example usage: obj.clear() without return types