Author: Ömer Bulut
Version: 1.3.0
Last Updated: August 16, 2025
- Overview
- Running Performance Tests
- Understanding Benchmark Results
- Performance Metrics
- Benchmark Analysis
- Performance Optimization
- Regression Detection
- Troubleshooting
FreshLogger includes comprehensive performance testing to ensure enterprise-grade performance. This guide explains how to run benchmarks, interpret results, and optimize performance.
- Throughput: >1M messages/second
- Latency: <1 μs average
- Memory: <100MB overhead
- Scalability: Linear scaling up to 16 threads
# Build performance tests
make performance_tests
# Run all performance tests
./performance_tests
# Run specific test
./performance_tests --gtest_filter="PerformanceTest.SynchronousThroughput"# Run complete enterprise test suite
make enterprise-test
# Run performance regression detection
make perf-regression
# Generate performance report
make perf-report./performance_tests --gtest_filter="PerformanceTest.SynchronousThroughput"Purpose: Measures single-threaded logging performance
./performance_tests --gtest_filter="PerformanceTest.AsynchronousThroughput"Purpose: Measures async logging performance with queue
./performance_tests --gtest_filter="PerformanceTest.SingleMessageLatency"Purpose: Measures individual message latency
./performance_tests --gtest_filter="PerformanceTest.MemoryUsageUnderLoad"Purpose: Measures memory consumption under load
./performance_tests --gtest_filter="PerformanceTest.MultiThreadedThroughput"Purpose: Measures concurrent logging performance
=== SYNCHRONOUS THROUGHPUT TEST ===
Messages: 10000
Duration: 2068 μs
Throughput: 4835589.94 msg/sec
[ OK ] PerformanceTest.SynchronousThroughput (2 ms)
Interpretation:
- Messages: 10,000 test messages
- Duration: 2,068 microseconds (2.068 ms)
- Throughput: 4,835,589.94 messages/second
- Status: ✅ PASSED (exceeds 1M msg/sec target)
=== ASYNCHRONOUS THROUGHPUT TEST ===
Messages: 100000
Duration: 23959 μs
Throughput: 4173796.90 msg/sec
[ OK ] PerformanceTest.AsynchronousThroughput (32 ms)
Interpretation:
- Messages: 100,000 test messages
- Duration: 23,959 microseconds (23.959 ms)
- Throughput: 4,173,796.90 messages/second
- Status: ✅ PASSED (exceeds 1M msg/sec target)
=== SINGLE MESSAGE LATENCY TEST ===
Average Latency: 0 μs
Min Latency: 0 μs
Max Latency: 6 μs
[ OK ] PerformanceTest.SingleMessageLatency (0 ms)
Interpretation:
- Average: 0 μs (sub-microsecond performance)
- Min: 0 μs (best case)
- Max: 6 μs (worst case)
- Status: ✅ PASSED (exceeds <1 μs target)
- Definition: Number of log messages processed per second
- Target: >1,000,000 msg/sec
- Measurement: High message volume over time
| Category | Range | Status | Use Case |
|---|---|---|---|
| Low | <100K msg/sec | Development | |
| Medium | 100K-1M msg/sec | ✅ Acceptable | Testing |
| High | 1M-10M msg/sec | 🚀 Excellent | Production |
| Extreme | >10M msg/sec | 🌟 Outstanding | High-performance |
- Definition: Time to process single log message
- Target: <1 μs average
- Measurement: Individual message timing
| Category | Range | Status | Impact |
|---|---|---|---|
| Ultra-low | <1 μs | 🚀 Excellent | Real-time systems |
| Low | 1-10 μs | ✅ Good | General applications |
| Medium | 10-100 μs | Non-critical systems | |
| High | >100 μs | ❌ Needs optimization | Performance issues |
- Definition: Memory consumed during logging
- Target: <100MB overhead
- Measurement: Before/after logging operations
| Category | Range | Status | Efficiency |
|---|---|---|---|
| Excellent | <10MB | 🚀 Outstanding | Highly efficient |
| Good | 10-50MB | ✅ Good | Efficient |
| Acceptable | 50-100MB | Moderate efficiency | |
| Poor | >100MB | ❌ Needs optimization | Inefficient |
=== BENCHMARK COMPARISON ===
Sync Logging: 2544529.26 msg/sec
Async Logging: 5102040.82 msg/sec
Multi-thread Async: 3125000.00 msg/sec
Analysis:
- Async is 2x faster than sync (5.1M vs 2.5M msg/sec)
- Multi-thread async provides balanced performance
- Sync logging is simpler but slower
=== MULTI-THREADED THROUGHPUT TEST ===
Threads: 8
Total Messages: 100000
Duration: 83241 μs
Throughput: 1201331.07 msg/sec
Analysis:
- 8 threads: 1.2M msg/sec
- Single thread: 2.5M msg/sec
- Scaling: Not linear due to synchronization overhead
=== PERFORMANCE REGRESSION TEST ===
Baseline Throughput: 7936507.94 msg/sec
Iteration 1 Throughput: 6289308.18 msg/sec (Ratio: 0.792)
Iteration 2 Throughput: 6250000.00 msg/sec (Ratio: 0.787)
Iteration 3 Throughput: 6451612.90 msg/sec (Ratio: 0.813)
Analysis:
- Baseline: 7.9M msg/sec (reference performance)
- Current: 6.2-6.4M msg/sec
- Regression: ~20% performance decrease
- Status:
⚠️ Performance regression detected
| Ratio | Status | Action Required |
|---|---|---|
| >0.95 | ✅ No regression | Continue development |
| 0.90-0.95 | Monitor closely | |
| 0.80-0.90 | ❌ Moderate regression | Investigate cause |
| <0.80 | 🚨 Major regression | Immediate fix required |
Logger::Config config;
config.asyncLogging = true; // Enable async logging
config.queueSize = 100000; // Large queue for bursts
config.flushInterval = 1; // Frequent flushing
config.maxFileSize = 100 * 1024 * 1024; // 100MB files
config.maxFiles = 3; // Fewer files for speedLogger::Config config;
config.asyncLogging = false; // Synchronous for low latency
config.consoleOutput = false; // Disable console for speed
config.maxFileSize = 10 * 1024 * 1024; // 10MB files
config.maxFiles = 2; // Minimal file rotationLogger::Config config;
config.asyncLogging = true; // Async reduces memory pressure
config.queueSize = 10000; // Smaller queue
config.flushInterval = 5; // Less frequent flushing
config.maxFileSize = 50 * 1024 * 1024; // 50MB files
config.maxFiles = 5; // Balanced file count// ❌ Inefficient
logger.info("Processing " + std::to_string(count) + " items");
// ✅ Efficient
logger.info("Processing {} items", count);
// ✅ Most efficient
logger.info("Processing " + std::to_string(count) + " items");// ❌ Always evaluates
logger.debug("Complex calculation: " + complexFunction());
// ✅ Conditional evaluation
if (logger.getLogLevel() <= Logger::LogLevel::DEBUG) {
logger.debug("Complex calculation: " + complexFunction());
}// ❌ Individual calls
for (const auto& item : items) {
logger.debug("Item: " + item.toString());
}
// ✅ Batch processing
std::string batch;
for (const auto& item : items) {
batch += "Item: " + item.toString() + "\n";
}
logger.debug(batch);# Create performance baseline
make perf-baseline
# This creates:
# - performance_baselines/baseline_YYYYMMDD_HHMMSS.json
# - Historical performance data# Detect performance regressions
make perf-regression
# This compares current performance against baseline
# - Generates regression report
# - Alerts if performance drops below threshold# Generate detailed performance report
make perf-report
# This creates:
# - HTML performance report
# - Performance trends
# - Optimization recommendations# Run performance tests multiple times
for i in {1..5}; do
./performance_tests --gtest_filter="PerformanceTest.SynchronousThroughput"
done
# Calculate average baseline
# Baseline: 4,835,589 msg/sec