diff --git a/.github/workflows/ls_perf_test.yml b/.github/workflows/ls_perf_test.yml new file mode 100644 index 000000000000..e785ce6422b0 --- /dev/null +++ b/.github/workflows/ls_perf_test.yml @@ -0,0 +1,42 @@ +name: LS perf tests + +on: + push: + branches: + - master + - ls-perf-tests-8 + workflow_dispatch: + +jobs: + ubuntu_build: + name: LS perf tests + runs-on: ubuntu-latest + timeout-minutes: 75 + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17.0.7' + + - name: Initialize sub-modules + run: git submodule update --init + + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ github.sha }} + restore-keys: ${{ runner.os }}-gradle + + - name: Build with Gradle + env: + packageUser: ${{ github.actor }} + packagePAT: ${{ secrets.GITHUB_TOKEN }} + run: | + export DISPLAY=':99.0' + chmod +x perf_test.sh & ./perf_test.sh diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CodeActionPerformanceTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CodeActionPerformanceTest.java index 2e34f11c32e9..a874e5444f62 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CodeActionPerformanceTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CodeActionPerformanceTest.java @@ -40,7 +40,7 @@ public String getResourceDir() { } @Override - @Test(dataProvider = "codeaction-data-provider", enabled = false) + @Test(dataProvider = "codeaction-data-provider") public void test(String config) throws IOException, WorkspaceDocumentException { super.test(config); } @@ -53,6 +53,7 @@ public String getResponse(Path sourcePath, Range range, CodeActionContext codeAc long end = System.currentTimeMillis(); long actualResponseTime = end - start; int expectedResponseTime = PerformanceTestUtils.getCodeActionResponseTimeThreshold(); + System.out.println("actualResponseTime: " + actualResponseTime); Assert.assertTrue(actualResponseTime < expectedResponseTime, String.format("Expected response time = %d, received %d.", expectedResponseTime, actualResponseTime)); return res; @@ -63,6 +64,7 @@ public String getResponse(Path sourcePath, Range range, CodeActionContext codeAc public Object[][] dataProvider() { return new Object[][]{ {"performance_codeaction.json"}, + {"performance_codeaction1.json"}, }; } } diff --git a/perf_test.sh b/perf_test.sh new file mode 100755 index 000000000000..f83773d0832d --- /dev/null +++ b/perf_test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Number of times to run the command +num_runs=10 + +# Initialize sum variable +sum=0 + +# Run the command multiple times +for ((i=1; i<=$num_runs; i++)); do + output=$(./gradlew :language-server:language-server-core:test --tests "org.ballerinalang.langserver.codeaction.CodeActionPerformanceTest") # Replace "your_command_here" with your actual command + response_time=$(echo "$output" | grep -oP 'actualResponseTime: \K\d+') + + if [[ -n $response_time ]]; then + sum=$((sum + response_time)) + echo "Run $i - actualResponseTime: $response_time" + else + echo "Run $i - actualResponseTime not found in output" + fi +done + +# Calculate the average +average=$((sum / num_runs)) + +echo "Average actualResponseTime: $average" +