forked from vadyushkins/kotgll
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test without jmh, add junit dataset
- Loading branch information
Showing
369 changed files
with
36,438 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
benchmarks/src/jmh/kotlin/org/Benchmarks.kt → benchmarks/src/main/kotlin/Benchmarks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
benchmarks/src/jmh/kotlin/org/Antlr.kt → benchmarks/src/test/kotlin/AntlrBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
package org | ||
|
||
import kotlinx.benchmark.* | ||
import org.antlr.Java8Lexer | ||
import org.antlr.Java8Parser | ||
import org.antlr.v4.runtime.CharStreams | ||
import org.antlr.v4.runtime.CommonTokenStream | ||
|
||
class AntlrBenchmark: TimeParsingBenchmark() { | ||
|
||
@State(Scope.Benchmark) | ||
class Antlr : BaseBench(){ | ||
override fun getShortName(): String = "Antlr" | ||
|
||
@Benchmark | ||
fun measureAntlr(blackhole: Blackhole) { | ||
@Override | ||
override fun parse(text: String) { | ||
val antlrParser = | ||
Java8Parser( | ||
CommonTokenStream( | ||
Java8Lexer( | ||
CharStreams.fromString(fileContents) | ||
CharStreams.fromString(text) | ||
) | ||
) | ||
) | ||
blackhole.consume(antlrParser.compilationUnit()) | ||
antlrParser.compilationUnit() | ||
} | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.ucfs.input.LinearInputLabel | ||
|
||
class OfflineUcfsBenchmark : TimeParsingBenchmark() { | ||
override fun getShortName(): String = "UcfsOff" | ||
|
||
override fun parse(text: String) { | ||
val parser = org.ucfs.Java8Parser<Int, LinearInputLabel>() | ||
parser.setInput(getTokenStream(text)) | ||
parser.parse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import java8.Java8 | ||
import org.ucfs.parser.Gll | ||
|
||
class OnlineUcfsBenchmark : TimeParsingBenchmark() { | ||
override fun getShortName(): String = "UcfsOn" | ||
|
||
override fun parse(text: String) { | ||
val startState = Java8().rsm | ||
val tokens = getTokenStream(text) | ||
val gll = Gll.gll(startState, tokens) | ||
gll.parse() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
benchmarks/src/test/kotlin/RecoveryOfflineUcfsBenchmark.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.ucfs.input.LinearInputLabel | ||
|
||
class RecoveryOfflineUcfsBenchmark : TimeParsingBenchmark() { | ||
override fun getShortName(): String = "RecUcfsOff" | ||
override fun parse(text: String) { | ||
val parser = org.ucfs.Java8ParserRecovery<Int, LinearInputLabel>() | ||
parser.setInput(getTokenStream(text)) | ||
parser.parse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import java8.Java8 | ||
import org.ucfs.parser.Gll | ||
|
||
class RecoveryOnlineUcfsBenchmark : TimeParsingBenchmark() { | ||
|
||
override fun getShortName(): String = "RecUcfsOn" | ||
|
||
|
||
override fun parse(text: String) { | ||
val startState = Java8().rsm | ||
val tokens = getTokenStream(text) | ||
val gll = Gll.gll(startState, tokens) | ||
gll.parse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import org.junit.jupiter.api.DynamicTest | ||
import org.junit.jupiter.api.DynamicTest.dynamicTest | ||
import org.junit.jupiter.api.TestFactory | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import kotlin.io.path.name | ||
|
||
abstract class TimeParsingBenchmark { | ||
|
||
|
||
val repeatCount: Int = 5 | ||
abstract fun getShortName(): String | ||
|
||
private fun runTimeTest(fileName: String, text: String) { | ||
var result: Long = 0 | ||
for(i in 0..repeatCount) { | ||
val startTime = System.currentTimeMillis() | ||
parse(text) | ||
result += System.currentTimeMillis() - startTime | ||
} | ||
result /= repeatCount | ||
val message = "$fileName,$result" | ||
println(message) | ||
File("${getShortName()}.csv").writeText(message) | ||
} | ||
|
||
abstract fun parse(text: String) | ||
|
||
private fun getResourceFolder(): String = Path.of("java", "correct").toString() | ||
|
||
|
||
private fun getResource(resourceFolder: String): Path { | ||
val res = TimeParsingBenchmark::class.java.getResource(resourceFolder) | ||
?: throw RuntimeException("No resource '$resourceFolder'") | ||
return Path.of(res.toURI()) | ||
} | ||
|
||
@TestFactory | ||
fun timeTest(): Collection<DynamicTest> { | ||
return getTests(getResource(getResourceFolder()), ::runTimeTest) | ||
} | ||
|
||
private fun getTests(folder: Path, run: (String, String) -> Unit): Collection<DynamicTest> { | ||
return Files.list(folder).map { file -> | ||
dynamicTest(file.fileName.toString()) { | ||
val source = file.toFile().readText() | ||
run(file.name, source) | ||
} | ||
}.toList() | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.