@@ -2,81 +2,81 @@ name: Performance Benchmarks
2
2
3
3
on :
4
4
push :
5
- branches : [ main, develop ]
5
+ branches : [main, develop]
6
6
pull_request :
7
- branches : [ main, develop ]
7
+ branches : [main, develop]
8
8
# Schedule benchmarks to run weekly
9
9
schedule :
10
- - cron : ' 0 0 * * 0' # Run at midnight on Sundays
10
+ - cron : " 0 0 * * 0" # Run at midnight on Sundays
11
11
12
12
jobs :
13
13
benchmark :
14
14
runs-on : ubuntu-latest
15
15
steps :
16
- - uses : actions/checkout@v3
17
- with :
18
- fetch-depth : 0 # Fetch all history for proper comparison
16
+ - uses : actions/checkout@v3
17
+ with :
18
+ fetch-depth : 0 # Fetch all history for proper comparison
19
19
20
- - name : Set up Python
21
- uses : actions/setup-python@v4
22
- with :
23
- python-version : ' 3.10'
24
- cache : ' pip'
25
-
26
- - name : Install dependencies
27
- run : |
28
- python -m pip install --upgrade pip
29
- pip install -e .
30
- pip install -r requirements-dev.txt
31
- pip install pytest-benchmark
32
-
33
- - name : Restore benchmark data
34
- uses : actions/cache@v3
35
- with :
36
- path : .benchmarks
37
- key : benchmark-${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}
38
- restore-keys : |
39
- benchmark-${{ runner.os }}-
40
-
41
- - name : Run benchmarks and save baseline
42
- run : |
43
- # Run benchmarks and save results
44
- pytest tests/benchmark_text_service.py -v --benchmark-autosave
45
-
46
- - name : Check for performance regression
47
- run : |
48
- # Compare against the previous benchmark if available
49
- # Fail if performance degrades by more than 10%
50
- if [ -d ".benchmarks" ]; then
51
- BASELINE=$(ls -t .benchmarks/Linux-CPython-3.10-64bit | head -n 2 | tail -n 1)
52
- CURRENT=$(ls -t .benchmarks/Linux-CPython-3.10-64bit | head -n 1)
53
- if [ -n "$BASELINE" ] && [ "$BASELINE" != "$CURRENT" ]; then
54
- # Set full paths to the benchmark files
55
- BASELINE_FILE="$benchmark_dir/$BASELINE"
56
- CURRENT_FILE="$benchmark_dir/$CURRENT"
57
-
58
- echo "Comparing current run ($CURRENT) against baseline ($BASELINE)"
59
- # First just show the comparison
60
- pytest tests/benchmark_text_service.py --benchmark-compare
61
-
62
- # Then check for significant regressions
63
- echo "Checking for performance regressions (>10% slower)..."
64
- # Use our Python script for benchmark comparison
65
- python scripts/compare_benchmarks.py "$BASELINE_FILE" "$CURRENT_FILE"
20
+ - name : Set up Python
21
+ uses : actions/setup-python@v4
22
+ with :
23
+ python-version : " 3.10"
24
+ cache : " pip"
25
+
26
+ - name : Install dependencies
27
+ run : |
28
+ python -m pip install --upgrade pip
29
+ pip install -e .
30
+ pip install -r requirements-dev.txt
31
+ pip install pytest-benchmark
32
+
33
+ - name : Restore benchmark data
34
+ uses : actions/cache@v3
35
+ with :
36
+ path : .benchmarks
37
+ key : benchmark-${{ runner.os }}-${{ hashFiles('**/requirements*.txt') }}
38
+ restore-keys : |
39
+ benchmark-${{ runner.os }}-
40
+
41
+ - name : Run benchmarks and save baseline
42
+ run : |
43
+ # Run benchmarks and save results
44
+ pytest tests/benchmark_text_service.py -v --benchmark-autosave
45
+
46
+ - name : Check for performance regression
47
+ run : |
48
+ # Compare against the previous benchmark if available
49
+ # Fail if performance degrades by more than 10%
50
+ if [ -d ".benchmarks" ]; then
51
+ BASELINE=$(ls -t .benchmarks/Linux-CPython-3.10-64bit | head -n 2 | tail -n 1)
52
+ CURRENT=$(ls -t .benchmarks/Linux-CPython-3.10-64bit | head -n 1)
53
+ if [ -n "$BASELINE" ] && [ "$BASELINE" != "$CURRENT" ]; then
54
+ # Set full paths to the benchmark files
55
+ BASELINE_FILE="$benchmark_dir/$BASELINE"
56
+ CURRENT_FILE="$benchmark_dir/$CURRENT"
57
+
58
+ echo "Comparing current run ($CURRENT) against baseline ($BASELINE)"
59
+ # First just show the comparison
60
+ pytest tests/benchmark_text_service.py --benchmark-compare
61
+
62
+ # Then check for significant regressions
63
+ echo "Checking for performance regressions (>10% slower)..."
64
+ # Use our Python script for benchmark comparison
65
+ python scripts/compare_benchmarks.py "$BASELINE_FILE" "$CURRENT_FILE"
66
+ else
67
+ echo "No previous benchmark found for comparison or only one benchmark exists"
68
+ fi
66
69
else
67
- echo "No previous benchmark found for comparison or only one benchmark exists "
70
+ echo "No benchmarks directory found"
68
71
fi
69
- else
70
- echo "No benchmarks directory found"
71
- fi
72
-
73
- - name : Upload benchmark results
74
- uses : actions/upload-artifact@v3
75
- with :
76
- name : benchmark-results
77
- path : .benchmarks/
78
-
79
- - name : Alert on regression
80
- if : failure()
81
- run : |
82
- echo "::warning::Performance regression detected! Check benchmark results."
72
+
73
+ - name : Upload benchmark results
74
+ uses : actions/upload-artifact@v3
75
+ with :
76
+ name : benchmark-results
77
+ path : .benchmarks/
78
+
79
+ - name : Alert on regression
80
+ if : failure()
81
+ run : |
82
+ echo "::warning::Performance regression detected! Check benchmark results."
0 commit comments