Fixture
provide.testkit.quality.profiling.fixture
¶
Performance profiling fixture for pytest integration.
Classes¶
ProfilingFixture
¶
Bases: BaseQualityFixture
Pytest fixture for performance profiling.
Provides easy access to performance profiling with automatic setup and teardown. Integrates with the quality framework fixtures.
Initialize profiling fixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | None
|
Profiler configuration |
None
|
artifact_dir
|
Path | None
|
Directory for artifacts |
None
|
Source code in provide/testkit/quality/profiling/fixture.py
Functions¶
assert_performance
¶
assert_performance(
func: Callable[..., Any],
max_memory_mb: float | None = None,
max_execution_time: float | None = None,
min_score: float | None = None,
*args: Any,
**kwargs: Any
) -> None
Assert performance requirements for a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
Function to test |
required |
max_memory_mb
|
float | None
|
Maximum memory usage in MB |
None
|
max_execution_time
|
float | None
|
Maximum execution time in seconds |
None
|
min_score
|
float | None
|
Minimum performance score |
None
|
*args
|
Any
|
Function arguments |
()
|
**kwargs
|
Any
|
Function keyword arguments |
{}
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If performance requirements are not met |
Source code in provide/testkit/quality/profiling/fixture.py
benchmark_function
¶
benchmark_function(
func: Callable[..., Any],
iterations: int = 100,
*args: Any,
**kwargs: Any
) -> dict[str, Any]
Benchmark a function over multiple iterations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
Function to benchmark |
required |
iterations
|
int
|
Number of iterations to run |
100
|
*args
|
Any
|
Function arguments |
()
|
**kwargs
|
Any
|
Function keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Benchmark results with statistics |
Source code in provide/testkit/quality/profiling/fixture.py
generate_report
¶
Generate profiling report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Report format (terminal, json) |
'terminal'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted report |
Source code in provide/testkit/quality/profiling/fixture.py
profile_cpu
¶
Profile CPU usage only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
Function to profile |
required |
*args
|
Any
|
Function arguments |
()
|
**kwargs
|
Any
|
Function keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
CPU profiling results |
Source code in provide/testkit/quality/profiling/fixture.py
profile_function
¶
Profile a function's performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
Function to profile |
required |
*args
|
Any
|
Function arguments |
()
|
**kwargs
|
Any
|
Function keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Profiling results as dict |
Source code in provide/testkit/quality/profiling/fixture.py
profile_memory
¶
Profile memory usage only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
Function to profile |
required |
*args
|
Any
|
Function arguments |
()
|
**kwargs
|
Any
|
Function keyword arguments |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Memory profiling results |
Source code in provide/testkit/quality/profiling/fixture.py
Functions¶
cpu_profiler
¶
Provide CPU-only profiling fixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiling_config
|
dict[str, Any]
|
Base configuration |
required |
Returns:
| Type | Description |
|---|---|
ProfilingFixture
|
ProfilingFixture configured for CPU profiling only |
Source code in provide/testkit/quality/profiling/fixture.py
memory_profiler
¶
Provide memory-only profiling fixture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiling_config
|
dict[str, Any]
|
Base configuration |
required |
Returns:
| Type | Description |
|---|---|
ProfilingFixture
|
ProfilingFixture configured for memory profiling only |
Source code in provide/testkit/quality/profiling/fixture.py
profiling_config
¶
Provide default profiling configuration.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Default configuration for profiling |
Source code in provide/testkit/quality/profiling/fixture.py
profiling_fixture
¶
Provide performance profiling fixture.
Returns:
| Type | Description |
|---|---|
ProfilingFixture
|
ProfilingFixture instance |