@@ -64,15 +64,20 @@ jobs:
6464 echo "version=$VERSION" >> $GITHUB_OUTPUT
6565 echo "Current branch has version $VERSION"
6666
67- # Build the current branch and save the fat jar
68- - name : Build with Maven (JDK ${{ matrix.jdk }})
69- run : mvn -B -Punix-amd64-profile package --file pom.xml
70-
71- # Save the fat jar for later use
72- - name : Save fat jar
67+ # Save the current branch name and jvector-examples directory
68+ - name : Save current branch and jvector-examples
7369 run : |
74- mkdir -p /tmp/jvector-jar
75- cp jvector-examples/target/jvector-examples-*-jar-with-dependencies.jar /tmp/jvector-jar/jvector-examples-fat.jar
70+ # Save current branch name
71+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
72+ echo "CURRENT_BRANCH=$CURRENT_BRANCH" >> $GITHUB_ENV
73+
74+ # Create a backup of the jvector-examples directory
75+ mkdir -p /tmp/jvector-backup
76+ cp -r jvector-examples /tmp/jvector-backup/
77+
78+ # Build the original branch to ensure jvector-examples is compiled
79+ - name : Build original branch
80+ run : mvn -B -Punix-amd64-profile package --file pom.xml
7681
7782 # Parse the branches input and run benchmarks for each branch
7883 - name : Run benchmarks for each branch
@@ -112,22 +117,48 @@ jobs:
112117 # Checkout the branch
113118 git checkout $branch || { echo "Failed to checkout branch $branch"; continue; }
114119
115- # Build the branch
120+ # Save the original jvector-examples directory from this branch if it exists
121+ if [ -d "jvector-examples" ]; then
122+ echo "Saving original jvector-examples from branch $branch"
123+ mkdir -p /tmp/branch-backup
124+ rm -rf /tmp/branch-backup/jvector-examples || true
125+ cp -r jvector-examples /tmp/branch-backup/
126+ fi
127+
128+ # Replace jvector-examples with the one from the original branch
129+ echo "Replacing jvector-examples with the one from the original branch"
130+ rm -rf jvector-examples
131+ cp -r /tmp/jvector-backup/jvector-examples .
132+
133+ # Build the branch with the injected jvector-examples
134+ echo "Building branch $branch with injected jvector-examples"
116135 mvn -B -Punix-amd64-profile package --file pom.xml
117136
118- # Run benchmark using the saved fat jar
137+ # Run the benchmark using the newly built jar with the branch's code and injected jvector-examples
138+ echo "Running benchmark for branch $branch"
119139 java ${{ matrix.jdk >= 20 && '--enable-native-access=ALL-UNNAMED --add-modules=jdk.incubator.vector' || '' }} \
120- -jar /tmp/ jvector-jar/ jvector-examples-fat .jar \
140+ -jar jvector-examples/target/ jvector-examples-*-jar-with-dependencies .jar \
121141 --config jvector-examples/yaml-configs/autoDefault.yml \
122142 --output ${branch}-bench-results
123143
124144 # Move the results to the benchmark_results directory
125145 mv ${branch}-bench-results.csv benchmark_results/
126146 mv ${branch}-bench-results.json benchmark_results/ || true
127147
148+ # Restore the original jvector-examples directory for this branch
149+ if [ -d "/tmp/branch-backup/jvector-examples" ]; then
150+ echo "Restoring original jvector-examples for branch $branch"
151+ rm -rf jvector-examples
152+ cp -r /tmp/branch-backup/jvector-examples .
153+ fi
154+
128155 echo "Completed benchmarks for branch: $branch"
129156 done
130157
158+ # Return to the original branch
159+ echo "Returning to original branch: $CURRENT_BRANCH"
160+ git checkout $CURRENT_BRANCH || echo "Failed to return to original branch $CURRENT_BRANCH"
161+
131162 - name : Upload Individual Benchmark Results
132163 uses : actions/upload-artifact@v4
133164 with :
0 commit comments