Skip to content

Commit 5efa0ff

Browse files
authored
Run sample benchmarks on CI (#622)
* Remove LSIF-related benchmarks
1 parent 9a8200e commit 5efa0ff

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ jobs:
2525
- name: Main project tests
2626
run: sbt test
2727

28+
benchmarks-test:
29+
runs-on: ubuntu-latest
30+
name: Benchmark tests
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-java@v3
34+
with:
35+
distribution: "temurin"
36+
cache: "sbt"
37+
java-version: 17
38+
- name: Run sample benchmarks
39+
run: sbt 'bench/Jmh/run -i 1 -f1 -t1 -foe true'
40+
2841
docker_test:
2942
runs-on: ${{ matrix.os }}
3043
name: Docker CLI tests

tests/benchmarks/src/main/scala/benchmarks/CompileBench.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ class CompileBench {
6262
@OutputTimeUnit(TimeUnit.MILLISECONDS)
6363
def compileSemanticdb(): Long = {
6464
CompileBench.foreachSource(deps) { inputs =>
65-
compiler.compileSemanticdb(inputs).textDocument.getOccurrencesCount
65+
compiler
66+
.compileSemanticdb(inputs)
67+
.textDocument
68+
.map(_.getOccurrencesCount)
69+
.getOrElse(0)
6670
}
6771
}
6872

@@ -74,10 +78,9 @@ object CompileBench {
7478
def foreachSource(
7579
deps: Dependencies
7680
)(fn: Seq[Input.VirtualFile] => Int): Long = {
77-
var sum = 0L
7881
deps
7982
.sources
80-
.foreach { source =>
83+
.map { source =>
8184
val path = AbsolutePath(source)
8285
FileIO.withJarFileSystem(path, create = false, close = true) { root =>
8386
val files =
@@ -91,9 +94,10 @@ object CompileBench {
9194
val relativePath = source.toString().stripPrefix("/")
9295
Input.VirtualFile(relativePath, text)
9396
}
94-
sum += fn(inputs)
97+
98+
fn(inputs)
9599
}
96100
}
97-
sum
101+
.sum
98102
}
99103
}

tests/benchmarks/src/main/scala/benchmarks/ScipSemanticdbBench.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ class ScipSemanticdbBench {
4848
@OutputTimeUnit(TimeUnit.MILLISECONDS)
4949
def json(): Unit = run("index.scip", parallel = false)
5050

51-
@Benchmark
52-
@BenchmarkMode(Array(Mode.SingleShotTime))
53-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
54-
def protobufParallel(): Unit = run("index.scip-protobuf", parallel = true)
55-
56-
@Benchmark
57-
@BenchmarkMode(Array(Mode.SingleShotTime))
58-
@OutputTimeUnit(TimeUnit.MILLISECONDS)
59-
def protobuf(): Unit = run("index.scip-protobuf", parallel = false)
60-
6151
private def run(filename: String, parallel: Boolean): Unit = {
6252
val output = Files.createTempFile("scip-java", filename)
6353
val parallelFlag =

tests/unit/src/main/scala/tests/CompileResult.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ case class CompileResult(
88
textDocuments: Semanticdb.TextDocuments,
99
isSuccess: Boolean
1010
) {
11-
def textDocument: Semanticdb.TextDocument = {
12-
textDocuments.getDocuments(0)
11+
def textDocument: Option[Semanticdb.TextDocument] = {
12+
Option.when(textDocuments.getDocumentsCount() > 0) {
13+
textDocuments.getDocuments(0)
14+
}
1315
}
1416

1517
def merge(other: CompileResult): CompileResult = {

tests/unit/src/test/scala/tests/OverridesSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class OverridesSuite extends FunSuite with TempDirectories {
2626
val relativePath = "example.Parent".replace('.', '/') + ".java"
2727
val input = Input.VirtualFile(relativePath, source)
2828
val result = compiler.compileSemanticdb(List(input))
29-
val symtab = new Symtab(result.textDocument)
29+
val symtab = new Symtab(result.textDocument.orNull)
3030

3131
val expectedSyms = expectedSymbols.mkString("\n")
3232
val syms = symtab

tests/unit/src/test/scala/tests/TargetedSuite.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class TargetedSuite extends FunSuite with TempDirectories {
4444
})
4545
.toList
4646
val result = compiler.compileSemanticdb(List(input))
47-
val occurrences = result.textDocument.getOccurrencesList.asScala.toList
47+
val textDocument = result.textDocument.orNull
48+
val occurrences = textDocument.getOccurrencesList.asScala.toList
4849
val symbols: List[String] = positions.map { pos =>
4950
val posRange = Semanticdb
5051
.Range
@@ -74,7 +75,7 @@ class TargetedSuite extends FunSuite with TempDirectories {
7475
)
7576
}
7677
}
77-
fn(result.textDocument, symbols)
78+
fn(textDocument, symbols)
7879
}
7980
}
8081

0 commit comments

Comments
 (0)