Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use jmh-sbt over scaliper for benchmarks
- Loading branch information
Showing
5 changed files
with
76 additions
and
75 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,54 @@ | ||
package svc | ||
|
||
import java.util.concurrent.TimeUnit | ||
import org.openjdk.jmh.annotations._ | ||
|
||
// --- // | ||
|
||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
class Bench { | ||
/* A single call to `get`, which fetches the current "stateful" value */ | ||
@Benchmark | ||
def oneGetCats: (Int, Int) = Kitties.oneGet | ||
|
||
@Benchmark | ||
def oneGetScalaz: (Int, Int) = Zed.oneGet | ||
|
||
/* Binding speed */ | ||
@Benchmark | ||
def bindCats: (Int, Unit) = Kitties.bind.run(1).value | ||
|
||
@Benchmark | ||
def flatMapCats: (Int, Unit) = Kitties.flatmap.run(1).value | ||
|
||
@Benchmark | ||
def bindScalaz: (Int, Unit) = Zed.bind.run(1) | ||
|
||
@Benchmark | ||
def flatMapScalaz: (Int, Unit) = Zed.flatmap.run(1) | ||
|
||
/* Count down by assigning each `n` to the State */ | ||
@Benchmark | ||
def countdownCats: (Int, Int) = Kitties.countdown.run(10000).value | ||
|
||
@Benchmark | ||
def countdownScalaz: (Int, Int) = Zed.trampolineCountdown.run(10000).run | ||
|
||
@Benchmark | ||
def countdownCatsStateTEitherT: Either[String, (Int, Unit)] = | ||
Kitties.countdownT.run(10000).value.value | ||
|
||
/* Silly summing using Applicative functors */ | ||
@Benchmark | ||
def cartesianSumCats: Option[Int] = Kitties.dumbSum(List.range(0, 1000)) | ||
|
||
@Benchmark | ||
def applicativeSumCats: Option[Int] = Kitties.dumbSum2(List.range(0, 1000)) | ||
|
||
@Benchmark | ||
def cartesianSumScalaz: Option[Int] = Zed.dumbSum(List.range(0, 1000)) | ||
|
||
@Benchmark | ||
def applicativeSumScalaz: Option[Int] = Zed.dumbSum2(List.range(0, 1000)) | ||
} |
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 @@ | ||
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27") |
This file was deleted.
Oops, something went wrong.