-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarking module (close #108)
- Loading branch information
Showing
5 changed files
with
57 additions
and
0 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 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,6 @@ | ||
sourceDirectory in Jmh := (sourceDirectory in Test).value | ||
classDirectory in Jmh := (classDirectory in Test).value | ||
dependencyClasspath in Jmh := (dependencyClasspath in Test).value | ||
// rewire tasks, so that 'jmh:run' automatically invokes 'jmh:compile' (otherwise a clean 'jmh:run' would fail) | ||
compile in Jmh := (compile in Jmh).dependsOn(compile in Test).value | ||
run in Jmh := (run in Jmh).dependsOn(Keys.compile in Jmh).evaluated |
35 changes: 35 additions & 0 deletions
35
...a/com.snowplowanalytics.snowplow.analytics.scalasdk/benchmark/BenchmarkAnalyticsSDK.scala
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,35 @@ | ||
package com.snowplowanalytics.snowplow.analytics.scalasdk.benchmark | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import java.util.concurrent.TimeUnit | ||
import java.util.UUID | ||
import java.time.Instant | ||
|
||
import com.snowplowanalytics.snowplow.analytics.scalasdk.Event | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.AverageTime, Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
class BenchmarkAnalyticsSDK { | ||
@Benchmark | ||
def ordered(state : States.AtomicEventState): Unit = { | ||
state.event.ordered | ||
} | ||
} | ||
|
||
object States { | ||
@State(Scope.Benchmark) | ||
class AtomicEventState { | ||
var event: Event = _ | ||
|
||
@Setup(Level.Trial) | ||
def init(): Unit = { | ||
val uuid = UUID.randomUUID() | ||
val timestamp = Instant.now() | ||
val vCollector = "2.0.0" | ||
val vTracker = "scala_0.7.0" | ||
event = Event.minimal(uuid, timestamp, vCollector, vTracker) | ||
} | ||
} | ||
} |
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 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