CountMin sketch implementation.
Variables: |
|
---|
Adds an item.
Parameters: | item – An item. |
---|
Estimates the count for an item.
Parameters: | item – An item. |
---|---|
Returns: | The estimated count. |
Calculates the hash for a given item.
Parameters: |
|
---|---|
Returns: | The hash for the item. |
Given a function and LRU caching implementation, caches the results of the function.
Variables: |
|
---|
>>> from dautil import perf
>>> from functools import lru_cache
>>> cache = perf.LRUCache(lru_cache, lambda x: x)
>>> cache.cache()
>>> cache.cached(1)
1
>>> cache.cached(1)
1
>>> cache.hits_miss()
1.0
Caches the function.
Clears the cache.
Gets cache info.
Returns: | The hits/miss ratio. |
---|
A simple stopwatch, which has a context manager.
Variables: | elapsed – Elapsed time in seconds. |
---|
>>> from dautil import perf
>>> with perf.StopWatch() as sw:
... pass
...
>>> sw.elapsed
7.867813110351562e-06
Measures execution time of code (best of 3).
Parameters: |
|
---|---|
Returns: | The best execution time. |