用法:
dask.diagnostics.CacheProfiler(metric=None, metric_name=None)
用于在调度程序缓存级别执行 dask 的分析器。
- 记录每个任务的以下信息:
Key
Task
尺寸公制
自纪元以来的缓存进入时间(以秒为单位)
自纪元以来的缓存退出时间(以秒为单位)
例子:
>>> 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 [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=...)]
默认是对每个任务进行计数(对于所有任务,
metric
为 1)。其他函数可以通过metric
关键字用作度量。例如,cachey
中的nbytes
函数可用于测量缓存中的字节数。>>> from cachey import nbytes >>> with CacheProfiler(metric=nbytes) as prof: ... get(dsk, 'z') 22
可以使用
visualize
方法在散景图中可视化分析结果。请注意,这需要安装散景。>>> prof.visualize()
您可以全局激活分析器
>>> prof.register()
如果您在全局范围内使用分析器,则需要手动清除旧结果。
>>> prof.clear() >>> prof.unregister()
相关用法
- Python dask.diagnostics.Callback用法及代码示例
- Python dask.diagnostics.Profiler用法及代码示例
- Python dask.diagnostics.ResourceProfiler用法及代码示例
- Python dask.diagnostics.ProgressBar用法及代码示例
- Python dask.distributed.SSHCluster用法及代码示例
- Python dask.distributed.get_task_stream用法及代码示例
- Python dask.distributed.progress用法及代码示例
- Python dask.dataframe.Series.apply用法及代码示例
- Python dask.dataframe.to_records用法及代码示例
- Python dask.dataframe.DataFrame.applymap用法及代码示例
- Python dask.dataframe.Series.clip用法及代码示例
- Python dask.dataframe.Series.prod用法及代码示例
- Python dask.dataframe.Series.fillna用法及代码示例
- Python dask.dataframe.DataFrame.sub用法及代码示例
- Python dask.dataframe.compute用法及代码示例
- Python dask.dataframe.DataFrame.mod用法及代码示例
- Python dask.dataframe.Series.to_frame用法及代码示例
- Python dask.dataframe.read_table用法及代码示例
- Python dask.dataframe.read_hdf用法及代码示例
- Python dask.dataframe.Series.sum用法及代码示例
注:本文由纯净天空筛选整理自dask.org大神的英文原创作品 dask.diagnostics.CacheProfiler。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。