|
7 | 7 | # -m MARKER Pytest marker filter (default: "not production_server and not test_server") |
8 | 8 | # -d DURATION Number of slowest durations to show, 0 for all (default: 20) |
9 | 9 | # -t TIMEOUT Per-test timeout in seconds (default: 300) |
| 10 | +# -n WORKERS Number of parallel workers (default: 4) |
10 | 11 | # -o OUTPUT Output file path for the report (default: test_durations_report.txt) |
11 | 12 | # |
12 | 13 | # Examples: |
13 | 14 | # ./scripts/profile_tests.sh |
14 | 15 | # ./scripts/profile_tests.sh -m "production_server" -d 0 -t 600 |
15 | | -# ./scripts/profile_tests.sh -m "sklearn" -o sklearn_report.txt |
| 16 | +# ./scripts/profile_tests.sh -m "sklearn" -n 2 -o sklearn_report.txt |
16 | 17 |
|
17 | 18 | set -euo pipefail |
18 | 19 |
|
19 | 20 | # Default values |
20 | 21 | MARKER_FILTER="not production_server and not test_server" |
21 | 22 | DURATIONS=20 |
22 | 23 | TIMEOUT=300 |
| 24 | +NUM_WORKERS=4 |
23 | 25 | OUTPUT_FILE="test_durations_report.txt" |
24 | 26 |
|
25 | 27 | # Parse command line arguments |
26 | | -while getopts "m:d:t:o:" opt; do |
| 28 | +while getopts "m:d:t:n:o:" opt; do |
27 | 29 | case $opt in |
28 | 30 | m) MARKER_FILTER="$OPTARG" ;; |
29 | 31 | d) DURATIONS="$OPTARG" ;; |
30 | 32 | t) TIMEOUT="$OPTARG" ;; |
| 33 | + n) NUM_WORKERS="$OPTARG" ;; |
31 | 34 | o) OUTPUT_FILE="$OPTARG" ;; |
32 | | - *) echo "Usage: $0 [-m marker] [-d durations] [-t timeout] [-o output_file]" && exit 1 ;; |
| 35 | + *) echo "Usage: $0 [-m marker] [-d durations] [-t timeout] [-n workers] [-o output_file]" && exit 1 ;; |
33 | 36 | esac |
34 | 37 | done |
35 | 38 |
|
36 | 39 | echo "=== OpenML Test Duration Profiler ===" |
37 | 40 | echo "Marker filter: $MARKER_FILTER" |
38 | 41 | echo "Durations to show: $DURATIONS" |
39 | 42 | echo "Timeout per test: ${TIMEOUT}s" |
| 43 | +echo "Workers: $NUM_WORKERS" |
40 | 44 | echo "Output file: $OUTPUT_FILE" |
41 | 45 | echo "" |
42 | 46 |
|
43 | 47 | pytest \ |
| 48 | + --dist=load \ |
| 49 | + -n="$NUM_WORKERS" \ |
44 | 50 | --durations="$DURATIONS" \ |
45 | 51 | --timeout="$TIMEOUT" \ |
46 | | - -q \ |
47 | 52 | -m "$MARKER_FILTER" \ |
48 | 53 | 2>&1 | tee "$OUTPUT_FILE" |
49 | 54 |
|
|
0 commit comments