Browse Source

Modified finagle db tests so that they execute n queries

Patrick Falls 12 years ago
parent
commit
5e7242f597
1 changed files with 9 additions and 5 deletions
  1. 9 5
      finagle/src/main/scala/com/falmarri/finagle/Finagle.scala

+ 9 - 5
finagle/src/main/scala/com/falmarri/finagle/Finagle.scala

@@ -50,7 +50,7 @@ object FinagleBenchmark extends App {
     ds.setDriverClassName("com.mysql.jdbc.Driver")
     ds.setUsername("benchmarkdbuser")
     ds.setPassword("benchmarkdbpass")
-    ds.setMaxActive(20);
+    ds.setMaxActive(256);
     ds.setMaxIdle(10);
     ds.setInitialSize(20);
     //ds.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS")
@@ -89,8 +89,10 @@ object FinagleBenchmark extends App {
       val resp = Response()
       database withSession {implicit session: Session =>
         val rand = new Random()
-        val q = Query(Worlds).where(_.id inSet( for (i <- 0 to n) yield rand.nextInt(10000)))
-        resp.setContent(copiedBuffer(serialize(if (n == 1) q.first else q.list), UTF_8))
+        val q = (0 until n).map { _ =>
+          Query(Worlds).where(_.id > rand.nextInt(10000)).first
+        }
+        resp.setContent(copiedBuffer(serialize(q), UTF_8))
         resp.setContentTypeJson
         Future.value(resp)
       }
@@ -104,8 +106,10 @@ object FinagleBenchmark extends App {
 	      val resp = Response()
 	      database withSession {implicit session: Session =>
 	        val rand = new Random()
-	        val q = Query(Worlds).where(_.id inSet( for (i <- 0 to n) yield rand.nextInt(10000)))
-	        resp.setContent(copiedBuffer(serialize(if (n == 1) q.first else q.list), UTF_8))
+                val q = (0 until n).map { _ =>
+                  Query(Worlds).where(_.id > rand.nextInt(10000)).first
+                }
+                resp.setContent(copiedBuffer(serialize(q), UTF_8))
 	        resp.setContentTypeJson
 	        resp
 	      	}