-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
69 additions
and
52 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
33 changes: 33 additions & 0 deletions
33
ledger-service/http-json/src/bench/scala/com/daml/http/dbbackend/QueryBenchmark.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,33 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.http.dbbackend | ||
|
||
import scalaz.OneAnd | ||
import doobie.implicits._ | ||
import com.daml.http.domain.{Party} | ||
import org.openjdk.jmh.annotations._ | ||
|
||
class QueryBenchmark extends ContractDaoBenchmark { | ||
@Param(Array("10")) | ||
var batches: Int = _ | ||
|
||
@Setup(Level.Trial) | ||
override def setup(): Unit = { | ||
super.setup() | ||
(0 until batches - 1).foreach { batch => | ||
insertBatch("Alice", batch * batchSize) | ||
} | ||
insertBatch("Bob", (batches - 1) * batchSize) | ||
() | ||
} | ||
|
||
@Benchmark | ||
def run(): Unit = { | ||
implicit val driver: SupportedJdbcDriver = dao.jdbcDriver | ||
val result = dao | ||
.transact(ContractDao.selectContracts(OneAnd(Party("Bob"), Set.empty), tpid, fr"1 = 1")) | ||
.unsafeRunSync() | ||
assert(result.size == batchSize) | ||
} | ||
} |