Browse Source

Change to parallel collections

... and shamelessly copied the dispatch settings from here:
https://github.com/TechEmpower/FrameworkBenchmarks/pull/40
Skamander 12 years ago
parent
commit
135396c235
2 changed files with 26 additions and 5 deletions
  1. 4 4
      play-scala/app/controllers/Application.scala
  2. 22 1
      play-scala/conf/application.conf

+ 4 - 4
play-scala/app/controllers/Application.scala

@@ -22,13 +22,13 @@ object Application extends Controller {
     Async {
       val random = ThreadLocalRandom.current()
 
-      val worlds = Future.sequence( for {
-        _ <- (1 to queries)
-      } yield Future(World.findById(random.nextInt(TEST_DATABASE_ROWS) + 1)))
+      val worlds = Future.sequence( (for {
+        _ <- (1 to queries).par
+      } yield Future(World.findById(random.nextInt(TEST_DATABASE_ROWS) + 1))).toList)
 
       worlds map {
         w => Ok(Json.toJson(w))  
       } 
     }
-  }  
+  }     
 }

+ 22 - 1
play-scala/conf/application.conf

@@ -31,6 +31,7 @@ application.langs="en"
 # db.default.jndiName=DefaultDS
 db.default.driver= com.mysql.jdbc.Driver
 db.default.url="jdbc:mysql://localhost:3306/hello_world"
+#db.default.url="jdbc:mysql://192.168.100.101:3306/hello_world"
 db.default.user=benchmarkdbuser
 db.default.password=benchmarkdbpass
 db.default.jndiName=DefaultDS
@@ -63,4 +64,24 @@ logger.root=ERROR
 logger.play=ERROR
 
 # Logger provided to your application:
-logger.application=ERROR
+logger.application=ERROR
+
+play {
+  akka {
+    event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
+    loglevel = WARNING
+    actor {
+      default-dispatcher = {
+        fork-join-executor {
+          parallelism-factor = 1.0
+          parallelism-max = 50
+        }
+      }
+      application = {
+        fork-join-executor {
+          parallelism-max = 300
+        }
+      }
+    }
+  }
+}