Function Decorator#
@function_timer()#
Function decorator to measure the performance of a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thread | str | None | Option to start new thread. By default, the thread name is the function name. | None |
decimals | int | None | Option to define decimals for output. Minimum | 2 |
Example
Basic usage:
| Python | |
|---|---|
1 2 3 4 5 6 7 | |
How it appears in the terminal:
% Elapsed time: 12.34 seconds for thread TEST_FUNCTION With custom thread name and decimals:
| Python | |
|---|---|
1 2 3 4 5 6 7 | |
How it appears in the terminal:
% Elapsed time: 0.12345 seconds for thread CUSTOM The @function_timer automatically names the function and its arguments as thread name. For example:
| Python | |
|---|---|
1 2 3 4 5 6 7 | |
How it appears in the terminal:
% Elapsed time: 0.12 seconds for thread SUM_NUMBERS(A=1, B=2)