Skip to content

Commit

Permalink
Rename RunBenchmarkWithCodegen to SqlBasedBenchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyum committed Sep 24, 2018
1 parent 42230b6 commit 2d778a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ 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()
}
}

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()
}
}
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 =>
Expand Down

0 comments on commit 2d778a4

Please sign in to comment.