Browse Source

Update Hot benchmark implementation and framework version, add DB's (#4264)

* update framework and add mysql and prosgres benchmark

* merge hot bench files

* refactoring

* update to 0.9.15-SNAPSHOT version of hot

* removing vagrant-development files
Solimando Damien 6 years ago
parent
commit
e302171211

+ 38 - 0
frameworks/Groovy/hot/benchmark_config.json

@@ -38,6 +38,44 @@
       "display_name": "Hot",
       "notes": "",
       "versus": ""
+    }, "postgres" : {
+      "db_url": "/rest/db/pgsql",
+      "query_url": "/rest/queries/pgsql?queries=",
+      "fortune_url": "/rest/fortunes/pgsql",
+      "update_url": "/rest/updates/pgsql?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "Postgres",
+      "framework": "Hot",
+      "language": "Groovy",
+      "orm": "Raw",
+      "platform": "Jetty",
+      "webserver": "Jetty",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Hot",
+      "notes": "",
+      "versus": ""
+    }, "mysql" : {
+      "db_url": "/rest/db/mysql",
+      "query_url": "/rest/queries/mysql?queries=",
+      "fortune_url": "/rest/fortunes/mysql",
+      "update_url": "/rest/updates/mysql?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MySQL",
+      "framework": "Hot",
+      "language": "Groovy",
+      "orm": "Raw",
+      "platform": "Jetty",
+      "webserver": "Jetty",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Hot",
+      "notes": "",
+      "versus": ""
     }
   }]
 }

+ 16 - 0
frameworks/Groovy/hot/config-mysql.json

@@ -0,0 +1,16 @@
+{
+  "name": "techempower",
+  "version": "0.1",
+  "devMode": false,
+  "dataSources": [
+    {
+      "name": "mysql",
+      "engine": "MYSQL",
+      "hostname": "tfb-database",
+      "port": 3306,
+      "database": "hello_world",
+      "username": "benchmarkdbuser",
+      "password": "benchmarkdbpass"
+    }
+  ]
+}

+ 16 - 0
frameworks/Groovy/hot/config-pgsql.json

@@ -0,0 +1,16 @@
+{
+  "name": "techempower",
+  "version": "0.1",
+  "devMode": false,
+  "dataSources": [
+    {
+      "name": "pgsql",
+      "engine": "PGSQL",
+      "hostname": "tfb-database",
+      "port": 5432,
+      "database": "hello_world",
+      "username": "benchmarkdbuser",
+      "password": "benchmarkdbpass"
+    }
+  ]
+}

+ 1 - 1
frameworks/Groovy/hot/hot-mongodb.dockerfile

@@ -2,7 +2,7 @@ FROM openjdk:8-jdk
 WORKDIR /hot
 COPY shows shows
 COPY config.json config.json
-ENV HOT_VERSION 0.9.2-SNAPSHOT
+ENV HOT_VERSION 0.9.15-SNAPSHOT
 RUN curl -sL https://github.com/dsolimando/Hot/releases/download/${HOT_VERSION}/hot-${HOT_VERSION}.tar.gz | tar xz
 ENV HOT_HOME /hot/hot-${HOT_VERSION}
 ENV PATH ${HOT_HOME}:${PATH}

+ 9 - 0
frameworks/Groovy/hot/hot-mysql.dockerfile

@@ -0,0 +1,9 @@
+FROM openjdk:8-jdk
+WORKDIR /hot
+COPY shows shows
+COPY config-mysql.json config.json
+ENV HOT_VERSION 0.9.15-SNAPSHOT
+RUN curl -sL https://github.com/dsolimando/Hot/releases/download/${HOT_VERSION}/hot-${HOT_VERSION}.tar.gz | tar xz
+ENV HOT_HOME /hot/hot-${HOT_VERSION}
+ENV PATH ${HOT_HOME}:${PATH}
+CMD ["hot", "run"]

+ 9 - 0
frameworks/Groovy/hot/hot-postgres.dockerfile

@@ -0,0 +1,9 @@
+FROM openjdk:8-jdk
+WORKDIR /hot
+COPY shows shows
+COPY config-pgsql.json config.json
+ENV HOT_VERSION 0.9.15-SNAPSHOT
+RUN curl -sL https://github.com/dsolimando/Hot/releases/download/${HOT_VERSION}/hot-${HOT_VERSION}.tar.gz | tar xz
+ENV HOT_HOME /hot/hot-${HOT_VERSION}
+ENV PATH ${HOT_HOME}:${PATH}
+CMD ["hot", "run"]

+ 1 - 1
frameworks/Groovy/hot/hot.dockerfile

@@ -2,7 +2,7 @@ FROM openjdk:8-jdk
 WORKDIR /hot
 COPY shows shows
 COPY config.json config.json
-ENV HOT_VERSION 0.9.2-SNAPSHOT
+ENV HOT_VERSION 0.9.15-SNAPSHOT
 RUN curl -sL https://github.com/dsolimando/Hot/releases/download/${HOT_VERSION}/hot-${HOT_VERSION}.tar.gz | tar xz
 ENV HOT_HOME /hot/hot-${HOT_VERSION}
 ENV PATH ${HOT_HOME}:${PATH}

+ 89 - 73
frameworks/Groovy/hot/shows/benchmark.show.groovy

@@ -1,6 +1,10 @@
-import org.apache.commons.lang.StringEscapeUtils
+import org.apache.commons.lang3.StringEscapeUtils
+
+show.scale()
 
 def mongo = show.dbs.mongo
+def pgsqldb = show.dbs.pgsql
+def mysql = show.dbs.mysql
 
 def generator = new Random ()
 
@@ -8,10 +12,6 @@ def generate = {
 	Math.max(generator.nextInt(10000),1)
 }
 
-def templateHeader = """<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"""
-
-def templateTail = """</table></body></html>"""
-
 def validateNumQueries = {
 	Integer numQueries
 
@@ -22,85 +22,101 @@ def validateNumQueries = {
 	} catch (e) {
 		numQueries = 1
 	}
-	numQueries = Math.max(1,Math.min(500,numQueries))
+	Math.max(1,Math.min(500,numQueries))
 }
 
-rest.get("/json").then {
-	[message:'Hello, World!']
+def query = { db, idLabel = '_id' ->
+    db.world.findOne([(idLabel):generate()])
 }
 
-rest.get('/db/mongodb').then {
-	mongo.world.findOne([_id:generate()]).promise()
+rest.get('/db/mongodb').then { query mongo }
+rest.get('/db/pgsql').then { query pgsqldb, 'id' }
+rest.get('/db/mysql').then { query mysql, 'id' }
+
+def queries = { req, db, idLabel = '_id' ->
+
+    def numQueries = validateNumQueries(req?.requestParams?.queries)
+    def deferred = show.Deferred()
+    def promise = deferred.promise()
+    def results = []
+
+    (1..numQueries).each { i ->
+        promise = promise.then {
+            db.world.findOne((idLabel):generate())
+        }.then { world ->
+            results << world
+            results
+        }
+    }
+    deferred.resolve()
+    promise
 }
 
-rest.get('/queries/mongodb').then { req ->
-	
-	def numQueries = validateNumQueries(req?.requestParams?.queries)
-	def deferred = show.Deferred()
-	def promise = deferred.promise()
-	def results = []
-
-	(1..numQueries).each { i ->
-		promise = promise.then { 
-			mongo.world.findOne(_id:generate()).promise()
-		}.then { world ->
-			results << world
-			results
-		}
-	}
-	deferred.resolve()
-	promise
+rest.get('/queries/mongodb').then { req -> queries req, mongo }
+rest.get('/queries/pgsql').then { req -> queries req, pgsqldb, 'id' }
+rest.get('/queries/mysql').then { req -> queries req, mysql, 'id' }
+
+def template = { content ->
+    """<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>
+$content
+</table></body></html>
+"""
 }
 
-rest.get('/fortunes/mongodb').then {
+def fortune = { db, idLabel = '_id', parseId = { it } ->
+    db.fortune.find().promise().then { fortunes ->
+
+        fortunes << [(idLabel):'0', message:'Additional fortune added at request time.']
+        response = template(fortunes
+                .sort { it.message }
+                .collect({
+                    "<tr><td>${parseId(it[idLabel])}</td><td>${StringEscapeUtils.escapeHtml4(it.message)}</td></tr>"
+                }).join('')
+        )
+        new hot.Response(200,['Content-Type':'text/html'], response)
+    }
+}
 
-	mongo.fortune.find().promise().then { fortunes ->
-		
-		fortunes << [_id:'0.', message:'Additional fortune added at request time.']
-		fortunes.each {
-			it._id = Float.parseFloat(it._id) as Integer
-			if (it.message.contains('<script>'))
-				it.message = StringEscapeUtils.escapeHtml(it.message)
-		}
-		fortunes.sort { it.message }
-		
-		def response = templateHeader
-		fortunes.each {
-			response += "<tr><td>${it._id}</td><td>${it.message}</td></tr>"
-		}
-		response += templateTail
-		new hot.Response(200,['Content-Type':'text/html'], response)
-	}
+rest.get('/fortunes/mongodb').then {
+    fortune mongo, '_id', { Float.parseFloat(it) as Integer }
+}
+rest.get('/fortunes/pgsql').then { fortune pgsqldb, 'id' }
+rest.get('/fortunes/mysql').then { fortune mysql, 'id' }
+
+def update = { req, db, idLabel = '_id' ->
+    def numQueries = validateNumQueries(req?.requestParams?.queries)
+
+    def deferred = show.Deferred()
+    def promise = deferred.promise()
+    def results = []
+
+    (1..numQueries).each { i ->
+        def genId = generate()
+
+        promise = promise.then {
+            db.world.findOne((idLabel):genId).promise()
+        }.then { world ->
+            world.randomNumber = generate()
+            db.world.update([(idLabel):genId],[$set:[randomNumber:world.randomNumber]]).then {
+                world
+            }
+        }.then { world ->
+            results << world
+            results
+        }
+    }
+    deferred.resolve()
+    promise
 }
 
-rest.get('/updates/mongodb').then { req ->
-	
-	def numQueries = validateNumQueries(req?.requestParams?.queries)
-	
-	def deferred = show.Deferred()
-	def promise = deferred.promise()
-	def results = []
-
-	(1..numQueries).each { i ->
-		def genId = generate()
-
-		promise = promise.then { 
-			mongo.world.findOne(_id:genId).promise()
-		}.then { world ->
-			world.randomNumber = generate()
-			mongo.world.update([_id:genId],[$set:[randomNumber:world.randomNumber]]).then {
-				world
-			}
-		}.then { world ->
-			results << world
-			results
-		}
-	}
-	deferred.resolve()
-	promise
+rest.get('/updates/mongodb').then { req -> update req, mongo }
+rest.get('/updates/pgsql').then { req -> update req, pgsqldb, 'id' }
+rest.get('/updates/mysql').then { req -> update req, mysql, 'id' }
+
+rest.get("/json").then {
+    [message:'Hello, World!']
 }
 
-def hello = 'Hello, World!'
 rest.get('/plaintext').then {
-	new hot.Response(200,['Content-Type':'text/plain'],hello)
-}
+    new hot.Response(200,['Content-Type':'text/plain'],'Hello, World!')
+}