用法:
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。