-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maxim Valyanskiy
committed
Jan 30, 2020
1 parent
71a0c2d
commit eeee462
Showing
6 changed files
with
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ _site | |
.jekyll-metadata | ||
vendor | ||
.bundle | ||
target | ||
.idea |
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 @@ | ||
sbt.version = 1.3.7 |
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,7 @@ | ||
name := "seminar2" | ||
|
||
version := "0.1" | ||
|
||
scalaVersion := "2.13.1" | ||
|
||
enablePlugins(JmhPlugin) |
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 @@ | ||
sbt.version = 1.3.7 |
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.3.7") |
24 changes: 24 additions & 0 deletions
24
code/seminar2/src/main/scala/benchmarks/CollectionBenchmarks.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,24 @@ | ||
package benchmarks | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
import org.openjdk.jmh.annotations._ | ||
|
||
import scala.util.Random | ||
|
||
// sbt | ||
// jmh:run -f 1 -i 1 | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
class CollectionBenchmarks { | ||
@Benchmark | ||
def listAppend(scope: BenchmarkState) = scope.randomList :+ 1 | ||
|
||
@Benchmark | ||
def listPrepend(scope: BenchmarkState) = 1 +: scope.randomList | ||
} | ||
|
||
@State(Scope.Benchmark) | ||
class BenchmarkState { | ||
val randomList: List[Int] = List.fill(10000)(Random.nextInt()) | ||
} |