Skip to content

Commit

Permalink
add benchmarks module with multi-projects structures
Browse files Browse the repository at this point in the history
  • Loading branch information
zeotuan committed Sep 3, 2024
1 parent 6e53ec5 commit 7b042f0
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.github.mrpowers.spark.fast.tests

import org.apache.spark.sql.Row
import org.openjdk.jmh.annotations._
import org.openjdk.jmh.infra.Blackhole

import java.time.Instant
import java.util.concurrent.TimeUnit

// TODO: move this to separate benchmark project
private class MyBenchmark {

@Benchmark
@BenchmarkMode(Array(Mode.AverageTime))
@Fork(value = 2)
@Warmup(iterations = 10)
@Measurement(iterations = 10)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
def testMethod(blackHole: Blackhole): Boolean = {
val r1 = Row(
"a",
Row(
1,
Row(
2.0,
Row(
null,
Row(
Seq(Row("c"), Row("d")),
BigDecimal.decimal(1.0),
Row(Instant.EPOCH)
)
)
)
)
)

val r2 = Row(
"a",
Row(
1,
Row(
2.0,
Row(
null,
Row(
Seq(Row("c"), Row("d")),
BigDecimal.decimal(1.0),
Row(Instant.EPOCH)
)
)
)
)
)
val bool = RowComparer.areRowsEqual(r1, r2)
blackHole.consume(bool)
bool
}
}
30 changes: 25 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,33 @@ crossScalaVersions := {

scalaVersion := crossScalaVersions.value.head

libraryDependencies += "org.apache.spark" %% "spark-sql" % sparkVersion.value % "provided"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.18" % "test"
Test / fork := true

credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credentials")
lazy val commonSettings = Seq(
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:+CMSClassUnloadingEnabled", "-Duser.timezone=GMT"),
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % "3.5.1" % "compile",
"org.scalatest" %% "scalatest" % "3.2.18" % "test"
),
)

Test / fork := true
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:+CMSClassUnloadingEnabled", "-Duser.timezone=GMT")
lazy val core = (project in file("core"))
.settings(
commonSettings,
name := "core",
)

lazy val benchmarks = (project in file("benchmarks"))
.dependsOn(core)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.openjdk.jmh" % "jmh-generator-annprocess" % "1.37" //required for jmh IDEA plugin. Make sure this version matches sbt-jmh version!
),
name := "benchmarks",
).enablePlugins(JmhPlugin)

credentials += Credentials(Path.userHome / ".sbt" / "sonatype_credentials")

licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT"))
homepage := Some(url("https:/mrpowers-io/spark-fast-tests"))
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")

addSbtPlugin("org.typelevel" % "laika-sbt" % "1.2.0")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")

0 comments on commit 7b042f0

Please sign in to comment.