Skip to content

Commit

Permalink
Run sample benchmarks on CI (#622)
Browse files Browse the repository at this point in the history
* Remove LSIF-related benchmarks
  • Loading branch information
keynmol authored Jul 26, 2023
1 parent 9a8200e commit 5efa0ff
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ jobs:
- name: Main project tests
run: sbt test

benchmarks-test:
runs-on: ubuntu-latest
name: Benchmark tests
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: "temurin"
cache: "sbt"
java-version: 17
- name: Run sample benchmarks
run: sbt 'bench/Jmh/run -i 1 -f1 -t1 -foe true'

docker_test:
runs-on: ${{ matrix.os }}
name: Docker CLI tests
Expand Down
14 changes: 9 additions & 5 deletions tests/benchmarks/src/main/scala/benchmarks/CompileBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class CompileBench {
@OutputTimeUnit(TimeUnit.MILLISECONDS)
def compileSemanticdb(): Long = {
CompileBench.foreachSource(deps) { inputs =>
compiler.compileSemanticdb(inputs).textDocument.getOccurrencesCount
compiler
.compileSemanticdb(inputs)
.textDocument
.map(_.getOccurrencesCount)
.getOrElse(0)
}
}

Expand All @@ -74,10 +78,9 @@ object CompileBench {
def foreachSource(
deps: Dependencies
)(fn: Seq[Input.VirtualFile] => Int): Long = {
var sum = 0L
deps
.sources
.foreach { source =>
.map { source =>
val path = AbsolutePath(source)
FileIO.withJarFileSystem(path, create = false, close = true) { root =>
val files =
Expand All @@ -91,9 +94,10 @@ object CompileBench {
val relativePath = source.toString().stripPrefix("/")
Input.VirtualFile(relativePath, text)
}
sum += fn(inputs)

fn(inputs)
}
}
sum
.sum
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ class ScipSemanticdbBench {
@OutputTimeUnit(TimeUnit.MILLISECONDS)
def json(): Unit = run("index.scip", parallel = false)

@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
def protobufParallel(): Unit = run("index.scip-protobuf", parallel = true)

@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
def protobuf(): Unit = run("index.scip-protobuf", parallel = false)

private def run(filename: String, parallel: Boolean): Unit = {
val output = Files.createTempFile("scip-java", filename)
val parallelFlag =
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/src/main/scala/tests/CompileResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ case class CompileResult(
textDocuments: Semanticdb.TextDocuments,
isSuccess: Boolean
) {
def textDocument: Semanticdb.TextDocument = {
textDocuments.getDocuments(0)
def textDocument: Option[Semanticdb.TextDocument] = {
Option.when(textDocuments.getDocumentsCount() > 0) {
textDocuments.getDocuments(0)
}
}

def merge(other: CompileResult): CompileResult = {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/test/scala/tests/OverridesSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OverridesSuite extends FunSuite with TempDirectories {
val relativePath = "example.Parent".replace('.', '/') + ".java"
val input = Input.VirtualFile(relativePath, source)
val result = compiler.compileSemanticdb(List(input))
val symtab = new Symtab(result.textDocument)
val symtab = new Symtab(result.textDocument.orNull)

val expectedSyms = expectedSymbols.mkString("\n")
val syms = symtab
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/src/test/scala/tests/TargetedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class TargetedSuite extends FunSuite with TempDirectories {
})
.toList
val result = compiler.compileSemanticdb(List(input))
val occurrences = result.textDocument.getOccurrencesList.asScala.toList
val textDocument = result.textDocument.orNull
val occurrences = textDocument.getOccurrencesList.asScala.toList
val symbols: List[String] = positions.map { pos =>
val posRange = Semanticdb
.Range
Expand Down Expand Up @@ -74,7 +75,7 @@ class TargetedSuite extends FunSuite with TempDirectories {
)
}
}
fn(result.textDocument, symbols)
fn(textDocument, symbols)
}
}

Expand Down

0 comments on commit 5efa0ff

Please sign in to comment.