Add BlockBench and benchmark README

This commit is contained in:
Chris Stewart 2018-11-21 14:01:03 -06:00
parent 718ad50427
commit dcb566526d
6 changed files with 66 additions and 1 deletions

15
bench/README.md Normal file
View file

@ -0,0 +1,15 @@
# Benchmark suite
This is a WIP. It currently contains one bench mark for de-serializing large blocks
You can assembly the jar like this
```
sbt bench/assembly
```
and then run with
```
$ java -Xprof -jar bench/target/scala-2.11/bench-assembly-0.0.1-SNAPSHOT.jar > output.txt
```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,33 @@
import org.bitcoins.core.protocol.blockchain.Block
import org.slf4j.LoggerFactory
import scala.io.Source
object BlockBench extends App {
private def logger = LoggerFactory.getLogger(this.getClass.getSimpleName)
private def timeBlockParsing[R](block: => R): Long = {
val t0 = System.currentTimeMillis()
val result = block // call-by-name
val t1 = System.currentTimeMillis()
val time = t1 - t0
logger.info("Elapsed time: " + (time) + "ms")
time
}
def bench1(): Unit = {
val fileName = "/00000000000000000008513c860373da0484f065983aeb063ebf81c172e81d48.txt"
val lines = Source.fromURL(getClass.getResource(fileName)).mkString
val time = timeBlockParsing(Block.fromHex(lines))
require(time <= 15000)
}
def bench2(): Unit = {
val fileName = "/000000000000000000050f70113ab1932c195442cb49bcc4ee4d7f426c8a3295.txt"
val lines = Source.fromURL(getClass.getResource(fileName)).mkString
val time = timeBlockParsing(Block.fromHex(lines))
require(time <= 15000)
}
bench1()
//bench2()
}

View file

@ -39,7 +39,8 @@ lazy val root = project
coreGen,
coreTest,
zmq,
rpc
rpc,
bench
)
.settings(commonSettings: _*)
@ -92,4 +93,11 @@ lazy val rpc = project
testOptions in Test += Tests.Argument("-oF")
)
lazy val bench = project
.in(file("bench"))
.enablePlugins()
.settings(assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = true))
.settings(libraryDependencies ++= Deps.bench)
.dependsOn(core)
publishArtifact in root := false

View file

@ -24,6 +24,8 @@ object Deps {
val akkaHttp = "com.typesafe.akka" %% "akka-http" % V.akkav withSources() withJavadoc()
val akkaStream = "com.typesafe.akka" %% "akka-stream" % V.akkaStreamv withSources() withJavadoc()
val playJson = "com.typesafe.play" %% "play-json" % V.playv withSources() withJavadoc()
val logback = "ch.qos.logback" % "logback-classic" % V.logback withSources() withJavadoc()
}
object Test {
@ -75,4 +77,9 @@ object Deps {
Test.scalaTest,
Test.scalacheck
)
val bench = List(
"org.slf4j" % "slf4j-api" % V.slf4j withSources() withJavadoc(),
Compile.logback
)
}