|
| 1 | +package org.jetbrains.kotlinx.dataframe.io |
| 2 | + |
| 3 | +import org.jetbrains.kotlinx.dataframe.DataFrame |
| 4 | +import org.openjdk.jmh.annotations.Benchmark |
| 5 | +import org.openjdk.jmh.annotations.BenchmarkMode |
| 6 | +import org.openjdk.jmh.annotations.Measurement |
| 7 | +import org.openjdk.jmh.annotations.Mode |
| 8 | +import org.openjdk.jmh.annotations.Param |
| 9 | +import org.openjdk.jmh.annotations.Scope |
| 10 | +import org.openjdk.jmh.annotations.Setup |
| 11 | +import org.openjdk.jmh.annotations.State |
| 12 | +import org.openjdk.jmh.annotations.TearDown |
| 13 | +import org.openjdk.jmh.annotations.Warmup |
| 14 | +import java.io.File |
| 15 | +import java.util.concurrent.TimeUnit |
| 16 | + |
| 17 | +@BenchmarkMode(Mode.SingleShotTime) |
| 18 | +@Warmup(iterations = 10, time = 5, timeUnit = TimeUnit.SECONDS) |
| 19 | +@Measurement(iterations = 20, timeUnit = TimeUnit.SECONDS) |
| 20 | +@State(Scope.Benchmark) |
| 21 | +open class BenchmarkTest { |
| 22 | + |
| 23 | + @Param("small", "medium", "large") |
| 24 | + var type = "" |
| 25 | + var file: File? = null |
| 26 | + |
| 27 | + @Setup |
| 28 | + fun setup() { |
| 29 | + System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info") |
| 30 | + file = File( |
| 31 | + "src/test/resources/" + when (type) { |
| 32 | + "small" -> "testCSV.csv" |
| 33 | + "medium" -> "gross-domestic-product-june-2024-quarter.csv" |
| 34 | + "large" -> "largeCsv.csv.gz" |
| 35 | + else -> throw IllegalArgumentException("Invalid type") |
| 36 | + }, |
| 37 | + ) |
| 38 | + } |
| 39 | + |
| 40 | + @TearDown |
| 41 | + fun tearDown() { |
| 42 | + file = null |
| 43 | + } |
| 44 | + |
| 45 | + @Benchmark |
| 46 | + fun apache() { |
| 47 | + DataFrame.readCSV(file!!) |
| 48 | + } |
| 49 | + |
| 50 | + @OptIn(ExperimentalCsv::class) |
| 51 | + @Benchmark |
| 52 | + fun deephaven() { |
| 53 | + DataFrame.readCsv(file!!) |
| 54 | + } |
| 55 | +} |
0 commit comments