- 55 CLI files: handlers/, aitbc_cli/commands/, cli/core/, cli/utils/, top-level scripts
- Click-based files: print() -> click.echo()
- Library modules: print() -> logger.info/error/warning
- Fixed pre-existing indentation bugs in monitor.py dashboard function
- Fixed bare print() -> logger.info('') in chain_manager.py
- 0 remaining print() in production CLI code
- All files compile cleanly
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
"""Performance command handlers for AITBC CLI."""
|
|
|
|
import json
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def handle_performance_benchmark(args, output_format, render_mapping):
|
|
"""Handle performance benchmark command."""
|
|
benchmark_data = {
|
|
"tps": 1250,
|
|
"latency_ms": 45,
|
|
"throughput_mbps": 850,
|
|
"cpu_usage": 65,
|
|
"memory_usage": 72,
|
|
"timestamp": __import__('datetime').datetime.now().isoformat()
|
|
}
|
|
|
|
if output_format(args) == "json":
|
|
logger.info(json.dumps(benchmark_data, indent=2))
|
|
else:
|
|
logger.info("Performance Benchmark:")
|
|
logger.info(f" TPS: {benchmark_data['tps']}")
|
|
logger.info(f" Latency: {benchmark_data['latency_ms']}ms")
|
|
logger.info(f" Throughput: {benchmark_data['throughput_mbps']}Mbps")
|
|
logger.info(f" CPU Usage: {benchmark_data['cpu_usage']}%")
|
|
logger.info(f" Memory Usage: {benchmark_data['memory_usage']}%")
|
|
def handle_performance_optimize(args, render_mapping):
|
|
"""Handle performance optimize command."""
|
|
target = getattr(args, "target", "general")
|
|
|
|
optimization_data = {
|
|
"target": target,
|
|
"optimization_applied": True,
|
|
"improvement": "15-20%",
|
|
"timestamp": __import__('datetime').datetime.now().isoformat()
|
|
}
|
|
|
|
logger.info(f"Performance optimization applied for {target}")
|
|
render_mapping("Optimization:", optimization_data)
|
|
|
|
|
|
def handle_performance_tune(args, render_mapping):
|
|
"""Handle performance tune command."""
|
|
parameters = getattr(args, "parameters", False)
|
|
aggressive = getattr(args, "aggressive", False)
|
|
|
|
tune_data = {
|
|
"parameters_tuned": parameters,
|
|
"aggressive_mode": aggressive,
|
|
"tuning_applied": True,
|
|
"timestamp": __import__('datetime').datetime.now().isoformat()
|
|
}
|
|
|
|
logger.info("Performance tuning applied")
|
|
render_mapping("Tuning:", tune_data)
|