From 8c8bc61ec1ef32105a484a3a919f8588deb419e0 Mon Sep 17 00:00:00 2001 From: takapi327 Date: Wed, 14 Aug 2024 12:43:23 +0900 Subject: [PATCH] Action sbt scalafmtAll --- .../benchmark/connector/jdbc/Select.scala | 20 ++++++------ .../benchmark/connector/ldbc/Select.scala | 22 ++++++------- .../benchmark/wrapper/doobie/Insert.scala | 24 ++++++++------ .../benchmark/wrapper/doobie/Select.scala | 14 ++++---- .../scala/benchmark/wrapper/ldbc/Insert.scala | 29 +++++++++-------- .../scala/benchmark/wrapper/ldbc/Select.scala | 32 +++++++++++-------- .../benchmark/wrapper/slick/Insert.scala | 8 ++--- 7 files changed, 81 insertions(+), 68 deletions(-) diff --git a/benchmark/src/main/scala/benchmark/connector/jdbc/Select.scala b/benchmark/src/main/scala/benchmark/connector/jdbc/Select.scala index 71f5a8ced..1aeee2c9e 100644 --- a/benchmark/src/main/scala/benchmark/connector/jdbc/Select.scala +++ b/benchmark/src/main/scala/benchmark/connector/jdbc/Select.scala @@ -80,16 +80,16 @@ class Select: @Benchmark def prepareStatement: List[BenchmarkType] = - connection - .use { conn => - for - statement <- conn.prepareStatement("SELECT * FROM jdbc_prepare_statement_test LIMIT ?") - _ <- statement.setInt(1, len) - resultSet <- statement.executeQuery() - records <- consume(resultSet) - yield records - } - .unsafeRunSync() + connection + .use { conn => + for + statement <- conn.prepareStatement("SELECT * FROM jdbc_prepare_statement_test LIMIT ?") + _ <- statement.setInt(1, len) + resultSet <- statement.executeQuery() + records <- consume(resultSet) + yield records + } + .unsafeRunSync() private def consume(resultSet: ResultSet[IO]): IO[List[BenchmarkType]] = def loop(acc: Vector[BenchmarkType]): IO[Vector[BenchmarkType]] = diff --git a/benchmark/src/main/scala/benchmark/connector/ldbc/Select.scala b/benchmark/src/main/scala/benchmark/connector/ldbc/Select.scala index bf5c623e5..bcfdfacf9 100644 --- a/benchmark/src/main/scala/benchmark/connector/ldbc/Select.scala +++ b/benchmark/src/main/scala/benchmark/connector/ldbc/Select.scala @@ -74,23 +74,23 @@ class Select: for statement <- conn.createStatement() resultSet <- statement.executeQuery(s"SELECT * FROM jdbc_statement_test LIMIT $len") - records <- consume(resultSet) + records <- consume(resultSet) yield records } .unsafeRunSync() @Benchmark def prepareStatement: List[BenchmarkType] = - connection - .use { conn => - for - statement <- conn.prepareStatement("SELECT * FROM jdbc_prepare_statement_test LIMIT ?") - _ <- statement.setInt(1, len) - resultSet <- statement.executeQuery() - records <- consume(resultSet) - yield records - } - .unsafeRunSync() + connection + .use { conn => + for + statement <- conn.prepareStatement("SELECT * FROM jdbc_prepare_statement_test LIMIT ?") + _ <- statement.setInt(1, len) + resultSet <- statement.executeQuery() + records <- consume(resultSet) + yield records + } + .unsafeRunSync() private def consume(resultSet: ResultSet[IO]): IO[List[BenchmarkType]] = def loop(acc: Vector[BenchmarkType]): IO[Vector[BenchmarkType]] = diff --git a/benchmark/src/main/scala/benchmark/wrapper/doobie/Insert.scala b/benchmark/src/main/scala/benchmark/wrapper/doobie/Insert.scala index bc0b82422..f9d112661 100644 --- a/benchmark/src/main/scala/benchmark/wrapper/doobie/Insert.scala +++ b/benchmark/src/main/scala/benchmark/wrapper/doobie/Insert.scala @@ -52,16 +52,20 @@ class Insert: @Benchmark def insertN: Unit = - transactor.use { xa => - (sql"INSERT INTO test (c1, c2)" ++ values(records)).update.run - .transact(xa) - }.unsafeRunSync() + transactor + .use { xa => + (sql"INSERT INTO test (c1, c2)" ++ values(records)).update.run + .transact(xa) + } + .unsafeRunSync() @Benchmark def batchN: Unit = - transactor.use { xa => - val sql = "INSERT INTO test (c1, c2) VALUES (?, ?)" - Update[(Int, String)](sql) - .updateMany(records) - .transact(xa) - }.unsafeRunSync() + transactor + .use { xa => + val sql = "INSERT INTO test (c1, c2) VALUES (?, ?)" + Update[(Int, String)](sql) + .updateMany(records) + .transact(xa) + } + .unsafeRunSync() diff --git a/benchmark/src/main/scala/benchmark/wrapper/doobie/Select.scala b/benchmark/src/main/scala/benchmark/wrapper/doobie/Select.scala index 8d146a3de..21d519aec 100644 --- a/benchmark/src/main/scala/benchmark/wrapper/doobie/Select.scala +++ b/benchmark/src/main/scala/benchmark/wrapper/doobie/Select.scala @@ -44,9 +44,11 @@ class Select: @Benchmark def selectN: List[(Int, String, String)] = - transactor.use { xa => - sql"SELECT ID, Name, CountryCode FROM city LIMIT $len" - .query[(Int, String, String)] - .to[List] - .transact(xa) - }.unsafeRunSync() + transactor + .use { xa => + sql"SELECT ID, Name, CountryCode FROM city LIMIT $len" + .query[(Int, String, String)] + .to[List] + .transact(xa) + } + .unsafeRunSync() diff --git a/benchmark/src/main/scala/benchmark/wrapper/ldbc/Insert.scala b/benchmark/src/main/scala/benchmark/wrapper/ldbc/Insert.scala index e6ca49715..f73d5c53c 100644 --- a/benchmark/src/main/scala/benchmark/wrapper/ldbc/Insert.scala +++ b/benchmark/src/main/scala/benchmark/wrapper/ldbc/Insert.scala @@ -49,7 +49,7 @@ class Insert: val datasource = jdbc.connector.MysqlDataSource[IO](ds) connection = Resource.make(datasource.getConnection)(_.close()) - + records = (1 to len).map(num => (num, s"record$num")).toList query = Table[Test] @@ -59,20 +59,23 @@ class Insert: @Benchmark def queryInsertN: Unit = - connection.use { conn => - query - .insertInto(test => (test.c1, test.c2)) - .values(records) - .update - .commit(conn) - }.unsafeRunSync() + connection + .use { conn => + query + .insertInto(test => (test.c1, test.c2)) + .values(records) + .update + .commit(conn) + } + .unsafeRunSync() @Benchmark def dslInsertN: Unit = - connection.use { conn => - (sql"INSERT INTO test (c1, c2)" ++ values(NonEmptyList.fromListUnsafe(records))) - .update - .commit(conn) - }.unsafeRunSync() + connection + .use { conn => + (sql"INSERT INTO test (c1, c2)" ++ values(NonEmptyList.fromListUnsafe(records))).update + .commit(conn) + } + .unsafeRunSync() case class Test(id: Option[Int], c1: Int, c2: String) derives Table diff --git a/benchmark/src/main/scala/benchmark/wrapper/ldbc/Select.scala b/benchmark/src/main/scala/benchmark/wrapper/ldbc/Select.scala index 5bbabc94d..b8eaa28b9 100644 --- a/benchmark/src/main/scala/benchmark/wrapper/ldbc/Select.scala +++ b/benchmark/src/main/scala/benchmark/wrapper/ldbc/Select.scala @@ -54,20 +54,24 @@ class Select: @Benchmark def querySelectN: List[(Int, String, String)] = - connection.use { conn => - query - .select(city => (city.id, city.name, city.countryCode)) - .limit(len) - .query - .to[List] - .readOnly(conn) - }.unsafeRunSync() + connection + .use { conn => + query + .select(city => (city.id, city.name, city.countryCode)) + .limit(len) + .query + .to[List] + .readOnly(conn) + } + .unsafeRunSync() @Benchmark def dslSelectN: List[(Int, String, String)] = - connection.use { conn => - sql"SELECT ID, Name, CountryCode FROM city LIMIT $len" - .query[(Int, String, String)] - .to[List] - .readOnly(conn) - }.unsafeRunSync() + connection + .use { conn => + sql"SELECT ID, Name, CountryCode FROM city LIMIT $len" + .query[(Int, String, String)] + .to[List] + .readOnly(conn) + } + .unsafeRunSync() diff --git a/benchmark/src/main/scala/benchmark/wrapper/slick/Insert.scala b/benchmark/src/main/scala/benchmark/wrapper/slick/Insert.scala index 79fccf4f7..1812c080c 100644 --- a/benchmark/src/main/scala/benchmark/wrapper/slick/Insert.scala +++ b/benchmark/src/main/scala/benchmark/wrapper/slick/Insert.scala @@ -63,10 +63,10 @@ class Insert: @Benchmark def batchN: Unit = - Await.result( - db.run(query ++= records), - Duration.Inf - ) + Await.result( + db.run(query ++= records), + Duration.Inf + ) case class Test(id: Option[Int], c1: Int, c2: String) class TestTable(tag: Tag) extends Table[Test](tag, "test"):