Skip to content

Commit

Permalink
SC-552 Complexity benchmarks (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrtm000 authored Jun 26, 2020
1 parent affcb39 commit 59f3719
Show file tree
Hide file tree
Showing 19 changed files with 1,034 additions and 282 deletions.
13 changes: 5 additions & 8 deletions benchmark/build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
enablePlugins(JmhPlugin)

libraryDependencies += "org.scodec" %% "scodec-core" % "1.11.7"

inTask(Compile / run)(
Seq(
fork := true,
javaOptions += s"-Dlogback.configurationFile=${(Compile / resourceDirectory).value / "logback.xml"}"
))
libraryDependencies ++= Seq(
"org.scodec" %% "scodec-core" % "1.11.7"
) ++ Dependencies.logDeps

// https://github.com/ktoso/sbt-jmh#adding-to-your-project
inConfig(Jmh)(
Expand All @@ -17,4 +13,5 @@ inConfig(Jmh)(
// rewire tasks, so that 'jmh:run' automatically invokes 'jmh:compile' (otherwise a clean 'jmh:run' would fail)
compile := compile.dependsOn(Test / compile).value,
run := run.dependsOn(compile).evaluated
))
)
)
3 changes: 0 additions & 3 deletions benchmark/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ waves.benchmark.state {
rest-txs-file = ""
rest-txs-from-height = 1

txs-addresses-file = ""
txs-addresses-from-height = 1

blocks-file = ""
blocks-from-height = 1

Expand Down
48 changes: 48 additions & 0 deletions benchmark/src/main/scala/com/wavesplatform/state/DBState.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.wavesplatform.state

import java.io.File

import com.wavesplatform.Application
import com.wavesplatform.account.AddressScheme
import com.wavesplatform.common.state.ByteStr
import com.wavesplatform.database.{LevelDBWriter, openDB}
import com.wavesplatform.lang.directives.DirectiveSet
import com.wavesplatform.settings.WavesSettings
import com.wavesplatform.transaction.smart.WavesEnvironment
import com.wavesplatform.utils.ScorexLogging
import monix.eval.Coeval
import org.iq80.leveldb.DB
import org.openjdk.jmh.annotations.{Param, Scope, State, TearDown}

@State(Scope.Benchmark)
abstract class DBState extends ScorexLogging {
@Param(Array("waves.conf"))
var configFile = ""

lazy val settings: WavesSettings = Application.loadApplicationConfig(Some(new File(configFile)).filter(_.exists()))

lazy val db: DB = openDB(settings.dbSettings.directory)

lazy val levelDBWriter: LevelDBWriter =
LevelDBWriter.readOnly(
db,
settings.copy(dbSettings = settings.dbSettings.copy(maxCacheSize = 1))
)

AddressScheme.current = new AddressScheme { override val chainId: Byte = 'W' }

lazy val environment = new WavesEnvironment(
AddressScheme.current.chainId,
Coeval.raiseError(new NotImplementedError("`tx` is not implemented")),
Coeval(levelDBWriter.height),
levelDBWriter,
null,
DirectiveSet.contractDirectiveSet,
ByteStr.empty
)

@TearDown
def close(): Unit = {
db.close()
}
}
150 changes: 0 additions & 150 deletions benchmark/src/main/scala/com/wavesplatform/state/ExtractInfo.scala

This file was deleted.

27 changes: 10 additions & 17 deletions benchmark/src/main/scala/com/wavesplatform/state/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,20 @@ package com.wavesplatform.state

import com.typesafe.config.Config
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._

case class Settings(networkConfigFile: String,
aliasesFile: String,
aliasesFromHeight: Int,
restTxsFile: String,
restTxsFromHeight: Int,
txsAddressesFile: String,
txsAddressesFromHeight: Int,
blocksFile: String,
blocksFromHeight: Int,
accountsFile: String,
accountsFromHeight: Int,
assetsFile: String,
assetsFromHeight: Int,
dataFile: String,
dataFromHeight: Int)
case class Settings(
networkConfigFile: String,
aliasesFile: String,
restTxsFile: String,
blocksFile: String,
accountsFile: String,
assetsFile: String,
dataFile: String
)

object Settings {
def fromConfig(config: Config): Settings = {
implicit val _ = net.ceedubs.ficus.readers.namemappers.HyphenNameMapper
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
config.as[Settings]("waves.benchmark.state")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object EnvironmentFunctionsBenchmark {
override def txId: ByteStr = ByteStr(new Array[Byte](64))
override def addressFromString(addressStr: String): Either[String, Recipient.Address] =
account.Address
.fromString(addressStr, chainId)
.fromString(addressStr)
.bimap(
_.toString,
address => Address(ByteStr(address.bytes))
Expand Down
Loading

0 comments on commit 59f3719

Please sign in to comment.