11
22package scorex .crypto .authds .benchmarks
33
4- /*
54import com .google .common .primitives .Ints
6- import org.mapdb.DB.TreeMapMaker
7- import org.mapdb.{BTreeMap, DBMaker, Serializer}
5+ import org .h2 .mvstore .MVStore
86import scorex .crypto .authds .TwoPartyDictionary .Label
97import scorex .crypto .authds ._
108import scorex .crypto .authds .avltree .batch .{BatchAVLProver , BatchAVLVerifier , Insert }
@@ -30,24 +28,24 @@ trait BenchmarkCommons {
3028
3129
3230trait TwoPartyCommons extends BenchmarkCommons with UpdateF [TreapValue ] {
33- lazy val db = DBMaker
31+ lazy val db = new MVStore .Builder ().
32+ fileName(" /tmp/proofs" ).
33+ cacheSize(1 ).
34+ open()
35+
36+ /* DBMaker
3437 .fileDB("/tmp/proofs")
3538 .closeOnJvmShutdown()
36- .make()
37-
38- lazy private val proofsMapMaker:TreeMapMaker[Integer, Array[Byte]] =
39- db.treeMap("proofs", Serializer.INTEGER, Serializer.BYTE_ARRAY)
39+ .make()*/
4040
41- lazy val proofsMap = proofsMapMaker.createOrOpen().asInstanceOf[BTreeMap[ Integer, Array[Byte]]]
41+ lazy val proofsMap = db.openMap[ Integer , Array [Byte ]]( " proofs " )
4242
4343 def set (value : TreapValue ): UpdateFunction = { oldOpt : Option [TreapValue ] => Try (Some (oldOpt.getOrElse(value))) }
4444
4545 lazy val balance = Array .fill(8 )(0 : Byte )
4646 lazy val bfn = set(balance)
4747
48- protected lazy val rootMap = db.treeMap("root", Serializer.STRING, Serializer.BYTE_ARRAY)
49- .createOrOpen()
50- .asInstanceOf[BTreeMap[String, Array[Byte]]]
48+ protected lazy val rootMap = db.openMap[String , Array [Byte ]](" root" )
5149
5250 def setRoot (newVal : Array [Byte ]) = rootMap.put(" root" , newVal)
5351
@@ -117,11 +115,7 @@ class Prover extends TwoPartyCommons with Initializing {
117115
118116
119117trait Batching extends TwoPartyCommons {
120- lazy val rootsMap: BTreeMap[Integer, Array[Byte]] = db.treeMap("roots")
121- .keySerializer(Serializer.INTEGER)
122- .valueSerializer(Serializer.BYTE_ARRAY)
123- .createOrOpen()
124- .asInstanceOf[BTreeMap[Integer, Array[Byte]]]
118+ lazy val rootsMap = db.openMap[Int , Array [Byte ]](" roots" )
125119}
126120
127121
@@ -229,13 +223,9 @@ class BatchVerifier extends TwoPartyCommons with Batching with Initializing {
229223}
230224
231225class FullWorker extends BenchmarkCommons with Initializing {
232- val store = DBMaker.fileDB ("/tmp/fulldb").make( )
226+ val store = MVStore .open (" /tmp/fulldb" )
233227
234- val map: BTreeMap[Array[Byte], Integer] = store.treeMap("proofs")
235- .keySerializer(Serializer.BYTE_ARRAY)
236- .valueSerializer(Serializer.INTEGER)
237- .createOrOpen()
238- .asInstanceOf[BTreeMap[Array[Byte], Integer]]
228+ val map = store.openMap[Array [Byte ], Int ](" proofs" )
239229
240230
241231 override protected def initStep (i : Int ) = {
@@ -360,9 +350,13 @@ trait BenchmarkLaunchers extends BenchmarkCommons {
360350 }
361351}
362352
363-
353+ /**
354+ * Todo: describe benches
355+ * todo: launchers
356+ */
364357object BlockchainBench extends BenchmarkLaunchers with App {
365- runBatchProver()
366- //runBatchVerifier()
358+ // runBatchProver()
359+ // runBatchVerifier()
360+
361+ runFullWorker()
367362}
368- */
0 commit comments