benchmark Module (stx.benchmark)
scitex-benchmark — performance benchmarking + monitoring + profiling (standalone).
This module provides tools for benchmarking and monitoring the performance of SciTeX functions.
- scitex.benchmark.benchmark_function(func, args=(), kwargs=None, iterations=10, warmup=2, input_size=None, measure_memory=False)[source]
Benchmark a single function.
- Parameters:
func (Callable) – Function to benchmark
args (tuple) – Arguments to pass to function
kwargs (dict) – Keyword arguments to pass to function
iterations (int) – Number of benchmark iterations
warmup (int) – Number of warmup iterations
input_size (str, optional) – Description of input size
measure_memory (bool) – Whether to measure memory usage
- Returns:
Benchmark results
- Return type:
- scitex.benchmark.benchmark_module(module_name, pattern='test_*')[source]
Create a benchmark suite for all matching functions in a module.
- Parameters:
- Returns:
Suite containing all matching benchmarks
- Return type:
- class scitex.benchmark.BenchmarkResult(function_name, module, mean_time, std_time, min_time, max_time, iterations, input_size=None, memory_usage=None, notes=None)[source]
Bases:
objectResults from a benchmark run.
- class scitex.benchmark.BenchmarkSuite(name)[source]
Bases:
objectCollection of benchmarks for a module or set of functions.
- scitex.benchmark.run_all_benchmarks(output_dir='./benchmark_results')[source]
Run all pre-defined benchmark suites.
- scitex.benchmark.compare_implementations(implementations, test_data_generator, iterations=10, sizes=None)[source]
Compare multiple implementations of the same functionality.
- Parameters:
- Returns:
Comparison results
- Return type:
pd.DataFrame
- scitex.benchmark.profile_function(func)[source]
Decorator to profile a function using the global profiler.
Example
>>> @profile_function ... def my_function(x): ... return sum(range(x))
- Return type:
- scitex.benchmark.profile_module(module_name, pattern='*')[source]
Profile all matching functions in a module.
- class scitex.benchmark.PerformanceMonitor(max_history=1000)[source]
Bases:
objectMonitor performance metrics for SciTeX functions.
Example
>>> monitor = PerformanceMonitor() >>> monitor.start() >>> # Your code here >>> stats = monitor.get_stats()