Test
performance_report(func, *args, save_path='need_profiling.prof', **kwargs)
Profiles the performance of a given function and saves the profiling report to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
callable
|
The function to be profiled. |
required |
*args
|
Variable length argument list to be passed to the function. |
()
|
|
**kwargs
|
Arbitrary keyword arguments to be passed to the function. |
{}
|
Returns:
| Type | Description |
|---|---|
|
None |
Side Effects
Creates a profiling report file named 'need_profiling.prof' in the current directory.
Source code in src/pymace/test/perftest.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
performance_time(repetitions, func, *args, output=None, **kwargs)
Measures the performance time of a given function by executing it a specified number of times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repetitions
|
int
|
The number of times to execute the function. |
required |
func
|
callable
|
The function to be executed. |
required |
*args
|
Variable length argument list to pass to the function. |
()
|
|
output
|
str
|
If set to "toConsole", the performance results will be logged to the console. Defaults to None. |
None
|
**kwargs
|
Arbitrary keyword arguments to pass to the function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float | None
|
The average time per execution in seconds if output is not "toConsole". |
Source code in src/pymace/test/perftest.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
getsize(obj)
Calculates the size of a given python object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
any
|
Python Object |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
Can't find the size of function and method type |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Size in Bytes |
Source code in src/pymace/test/size.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |