Skip to content

Commit

Permalink
Test LS Perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KavinduZoysa committed Nov 21, 2023
1 parent 03b5fb1 commit 23eb91d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ls_perf_test.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"},
};
}
}
26 changes: 26 additions & 0 deletions perf_test.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 23eb91d

Please sign in to comment.