diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/AggregateBenchmark.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/AggregateBenchmark.scala index 8fef8998eaa7e..0cfcf988e37d0 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/AggregateBenchmark.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/AggregateBenchmark.scala @@ -42,12 +42,12 @@ import org.apache.spark.unsafe.map.BytesToBytesMap * Results will be written to "benchmarks/AggregateBenchmark-results.txt". * }}} */ -object AggregateBenchmark extends RunBenchmarkWithCodegen { +object AggregateBenchmark extends SqlBasedBenchmark { override def benchmark(): Unit = { runBenchmark("aggregate without grouping") { val N = 500L << 22 - runBenchmark("agg w/o group", N) { + runBenchmarkWithCodegen("agg w/o group", N) { spark.range(N).selectExpr("sum(id)").collect() } } @@ -55,11 +55,11 @@ object AggregateBenchmark extends RunBenchmarkWithCodegen { runBenchmark("stat functions") { val N = 100L << 20 - runBenchmark("stddev", N) { + runBenchmarkWithCodegen("stddev", N) { spark.range(N).groupBy().agg("id" -> "stddev").collect() } - runBenchmark("kurtosis", N) { + runBenchmarkWithCodegen("kurtosis", N) { spark.range(N).groupBy().agg("id" -> "kurtosis").collect() } } @@ -283,7 +283,7 @@ object AggregateBenchmark extends RunBenchmarkWithCodegen { runBenchmark("cube") { val N = 5 << 20 - runBenchmark("cube", N) { + runBenchmarkWithCodegen("cube", N) { spark.range(N).selectExpr("id", "id % 1000 as k1", "id & 256 as k2") .cube("k1", "k2").sum("id").collect() } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/RunBenchmarkWithCodegen.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/SqlBasedBenchmark.scala similarity index 88% rename from sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/RunBenchmarkWithCodegen.scala rename to sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/SqlBasedBenchmark.scala index e2d93fef4a7c3..252911ee98115 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/RunBenchmarkWithCodegen.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/SqlBasedBenchmark.scala @@ -22,10 +22,9 @@ import org.apache.spark.sql.SparkSession import org.apache.spark.sql.internal.SQLConf /** - * Common base trait for micro benchmarks that are supposed to run standalone (i.e. not together - * with other test suites). + * Common base trait to run benchmark with the Dataset and DataFrame API. */ -trait RunBenchmarkWithCodegen extends BenchmarkBase { +trait SqlBasedBenchmark extends BenchmarkBase { val spark: SparkSession = getSparkSession @@ -40,7 +39,7 @@ trait RunBenchmarkWithCodegen extends BenchmarkBase { } /** Runs function `f` with whole stage codegen on and off. */ - def runBenchmark(name: String, cardinality: Long)(f: => Unit): Unit = { + def runBenchmarkWithCodegen(name: String, cardinality: Long)(f: => Unit): Unit = { val benchmark = new Benchmark(name, cardinality, output = output) benchmark.addCase(s"$name wholestage off", numIters = 2) { iter =>