profiling module¶
Utilities for profiling time and memory.
timeit function¶
Run timeit() on a function.
Usage
>>> from vectorbtpro import *
>>> def my_func():
... sleep(1)
>>> elapsed = vbt.timeit(my_func)
>>> print(elapsed)
1.01 seconds
>>> vbt.timeit(my_func, readable=False)
datetime.timedelta(seconds=1, microseconds=1870)
with_memtracer function¶
with_memtracer(
*args,
memtracer_kwargs=None,
usage_kwargs=None,
print_func=None,
print_format=None,
print_kwargs=None
)
Decorator to run a function with MemTracer.
with_timeit function¶
Decorator to run a function with timeit().
with_timer function¶
with_timer(
*args,
timer_kwargs=None,
elapsed_kwargs=None,
print_func=None,
print_format=None,
print_kwargs=None
)
Decorator to run a function with Timer.
MemTracer class¶
Context manager to trace peak and final memory usage using tracemalloc.
Usage
>>> from vectorbtpro import *
>>> with vbt.MemTracer() as tracer:
>>> np.random.uniform(size=1000000)
>>> print(tracer.peak_usage())
8.0 MB
>>> tracer.peak_usage(readable=False)
8005360
final_usage method¶
Get final memory usage.
**kwargs are passed to humanize.naturalsize.
peak_usage method¶
Get peak memory usage.
**kwargs are passed to humanize.naturalsize.
Timer class¶
Context manager to measure execution time using timeit().
Usage
>>> from vectorbtpro import *
>>> with vbt.Timer() as timer:
>>> sleep(1)
>>> print(timer.elapsed())
1.01 seconds
>>> timer.elapsed(readable=False)
datetime.timedelta(seconds=1, microseconds=5110)
elapsed method¶
Get elapsed time.
**kwargs are passed to humanize.precisedelta.
end_time property¶
End time.
start_time property¶
Start time.