Welcome to Simple Utilities’s documentation!¶
Contents:
Bench decorator¶
-
decbench.
bench
(func)[source]¶ Decorator to time a function.
Parameters: Returns: real time to execute f and result of f
Return type: Example:
>>> from time import sleep >>> @bench ... def super_func(numbers): ... sleep(1) ... return numbers >>> bench_time, func_res = super_func([3, 4, 5]) >>> 1. < bench_time < 1.1 True >>> func_res [3, 4, 5]
Fork decorator¶
-
decfork.
fork
(n)[source]¶ Decorator to fork a function many times.
Parameters: n (int) – number of forks to make. Returns: None Example
>>> from time import sleep >>> @fork(n=3) ... def my_func_to_fork(): ... print('Starting...') ... sleep(1) ... print('done') >>> my_func_to_fork()
will output
'Starting...' 'Starting...' 'Starting...' 'done' 'done' 'done'