Browse Source

Merge branch 'master' of te.github.com:TechEmpower/FrameworkBenchmarks

Patrick Falls 12 years ago
parent
commit
ebc5d0c75d
2 changed files with 12 additions and 8 deletions
  1. 9 5
      finagle/src/main/scala/com/falmarri/finagle/Finagle.scala
  2. 3 3
      go/src/hello/hello.go

+ 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
 	      	}

+ 3 - 3
go/src/hello/hello.go

@@ -21,8 +21,8 @@ type World struct {
 }
 
 const (
-	DB_CONN_STR   = "benchmarkdbuser:benchmarkdbpass@tcp(localhost:3306)/hello_world?charset=utf8"
-	DB_SELECT_SQL = "SELECT * FROM World where id = ?;"
+	DB_CONN_STR   = "benchmarkdbuser:benchmarkdbpass@tcp(172.16.98.98:3306)/hello_world?charset=utf8"
+	DB_SELECT_SQL = "SELECT id, randomNumber FROM World where id = ?;"
 	DB_ROWS       = 10000
 )
 
@@ -53,7 +53,7 @@ func jsonHandler(w http.ResponseWriter, r *http.Request) {
 }
 
 func dbHandler(w http.ResponseWriter, r *http.Request) {
-	qnum := 1
+  	qnum := 1
 	if qnumStr := r.URL.Query().Get("queries"); len(qnumStr) != 0 {
 		qnum, _ = strconv.Atoi(qnumStr)
 	}