Add benchmark for backtest on the test

This commit is contained in:
2025-11-11 11:23:30 +07:00
parent 2ca77bc2f9
commit 14d101b63e
8 changed files with 360 additions and 43 deletions

View File

@@ -0,0 +1,70 @@
# Benchmark Backtest Performance
This command runs the backtest performance tests and records the results in the performance benchmark CSV file.
## Usage
Run this command to benchmark backtest performance and update the tracking CSV:
```
/benchmark-backtest-performance
```
Or run the script directly:
```bash
./scripts/benchmark-backtest-performance.sh
```
## What it does
1. Runs the performance telemetry test (`ExecuteBacktest_With_Large_Dataset_Should_Show_Performance_Telemetry`)
2. Extracts performance metrics from the test output
3. Appends a new row to `src/Managing.Workers.Tests/performance-benchmarks.csv`
## CSV Format
The CSV file contains the following columns:
- `DateTime`: ISO 8601 timestamp when the benchmark was run
- `TestName`: Name of the test that was executed
- `CandlesCount`: Number of candles processed
- `ExecutionTimeSeconds`: Total execution time in seconds
- `ProcessingRateCandlesPerSec`: Candles processed per second
- `MemoryStartMB`: Memory usage at start
- `MemoryEndMB`: Memory usage at end
- `MemoryPeakMB`: Peak memory usage
- `SignalUpdatesCount`: Total signal updates performed
- `SignalUpdatesSkipped`: Number of signal updates skipped
- `SignalUpdateEfficiencyPercent`: Percentage of signal updates that were skipped
- `BacktestStepsCount`: Number of backtest steps executed
- `AverageSignalUpdateMs`: Average time per signal update
- `AverageBacktestStepMs`: Average time per backtest step
- `FinalPnL`: Final profit and loss
- `WinRatePercent`: Win rate percentage
- `GrowthPercentage`: Growth percentage
- `Score`: Backtest score
- `CommitHash`: Git commit hash
- `GitBranch`: Git branch name
- `Environment`: Environment where test was run
## Implementation Details
The command uses regex patterns to extract metrics from the test console output and formats them into CSV rows. It automatically detects the current git branch and commit hash for tracking.
## Example Output
```
🚀 Running backtest performance benchmark...
📊 Test Results:
• Processing Rate: 2,684.8 candles/sec
• Execution Time: 2.15s
• Memory Usage: 24.24MB peak
• Signal Efficiency: 33.1%
✅ Benchmark data recorded in performance-benchmarks.csv
```
## Files Modified
- `src/Managing.Workers.Tests/performance-benchmarks.csv` - Performance tracking data