# py-logging-test **Repository Path**: adamhall/py-logging-test ## Basic Information - **Project Name**: py-logging-test - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-10 - **Last Updated**: 2026-02-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 日志框架性能压测代码 ## 1. 压测工具包完整实现 ### `logger_benchmark.py` ## 2. 各框架压测实现 ### `logging_benchmark.py` ### `loguru_benchmark.py` ### `structlog_benchmark.py` ## 3. 综合压测执行器 ### `run_benchmarks.py` ## 4. 快速启动脚本 ### `start_benchmark.sh` (Linux/Mac) ### `requirements.txt` ``` loguru>=0.7.0 structlog>=23.1.0 psutil>=5.9.0 pandas>=1.5.0 matplotlib>=3.6.0 seaborn>=0.12.0 numpy>=1.23.0 ``` ## 5. 压测报告示例 运行后会生成以下文件: ``` benchmark_results/ ├── Python_Logging_20231201_143022.json ├── Loguru_20231201_143125.json ├── Structlog_20231201_143230.json └── reports/ ├── throughput_comparison_20231201_143230.png ├── latency_comparison_20231201_143230.png ├── memory_comparison_20231201_143230.png ├── radar_chart_20231201_143230.png └── benchmark_report_20231201_143230.txt ``` ## 6. 使用说明 1. **安装依赖**: ```bash pip install -r requirements.txt ``` 2. **运行完整压测**: ```bash python run_benchmarks.py ``` 3. **单独测试某个框架**: ```python from logging_benchmark import LoggingBenchmark bench = LoggingBenchmark() bench.run_all_tests() ``` 4. **自定义压测参数**: 修改 `logger_benchmark.py` 中的: - `NUM_MESSAGES`: 测试消息总数 - `NUM_THREADS`: 并发线程数 - `NUM_ASYNC_TASKS`: 异步任务数 ## 7. 关键特性测试说明 1. **吞吐量测试**:测试单线程连续写入能力 2. **并发测试**:测试多线程同时写入的线程安全性 3. **内存测试**:测试大量日志写入时的内存占用 4. **延迟测试**:测试单条日志处理的平均延迟 5. **功能测试**:测试各框架特有功能(上下文、结构化等)