Browse Source

Merged in PR501

tfb 12 years ago
parent
commit
ec65e58c00

+ 2 - 51
README.md

@@ -40,58 +40,9 @@ When adding a new framework or new test to an existing framework, please follow
 * Update/add [setup file](#setup-files)
 * Update/add [setup file](#setup-files)
 * When creating a database test, please use the MySQL table hello_world.World, or the MongoDB collection hello_world.world
 * When creating a database test, please use the MySQL table hello_world.World, or the MongoDB collection hello_world.world
 
 
-There are three different tests that we currently run:
+### The Tests
 
 
-* JSON Response
-* Database (single query)
-* Database (multiple query)
-
-The single query database test can be treated as a special case of the multiple query test with the query-count parameter set to 1.
-
-### JSON Response
-
-This test needs to follow the following conventions:
-
-* The message object should be instantiated as a new object for each request.
-* The test should use a JSON serializer to render the newly instantiated object to JSON.
-* Set the response Content-Type to application/json.
-* The response should be {"message": "Hello, World!"}
-* White space in the response does not matter.
-
-Pseudo-code:
-
-	obj = { message : "Hello, World!" }
-	render json.encode(obj)
-
-### Database (single query)
-
-This test will:
-
-* Access a database table or collection named "World" that is known to contain 10,000 rows/entries.
-* Query for a single row from the table or collection using a randomly generated id (the ids range from 1 to 10,000).
-* Set the response Content-Type to application/json.
-* Serialize the row to JSON and send the resulting string as the response.
-
-By convention, if the test does not use an ORM, and instead uses the raw database connectivity provided by the platform (e.g., JDBC), we append a "-raw" to the test name in the [benchmark_config](#the-benchmark_config-file) file.  For example, "php-raw".
-
-Pseudo-code:
-
-	random_id = random(1, 10000)
-	world = World.find(random_id)
-	render json.encode(world)
-
-### Database (multiple queries)
-
-This test is very similar to the single query test, and in some cases it will be implemented using the same code. A URL parameter is made available to specify the number of queries to run per request. The response is a list of objects resulting from the queries for random rows.
-
-Pseudo-code:
-
-	number_of_queries = get("queries")
-	worlds = []
-	for i = 0; i < number_of_queries; i++
-        random_id = random(1, 10000)
-        worlds[i] = World.find(random_id)
-	render json.encode(worlds)
+For descriptions of the test types that we run against each framework, see the [test requirements section of the Results web site](http://www.techempower.com/benchmarks/#section=code).
 
 
 ## The benchmark_config File
 ## The benchmark_config File
 
 

+ 1 - 2
config/benchmark_profile

@@ -1,8 +1,7 @@
 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
 export RESIN_HOME=~/FrameworkBenchmarks/installs/resin-4.0.36
 export RESIN_HOME=~/FrameworkBenchmarks/installs/resin-4.0.36
 export GRAILS_HOME=~/FrameworkBenchmarks/installs/grails-2.1.1
 export GRAILS_HOME=~/FrameworkBenchmarks/installs/grails-2.1.1
-#export VERTX_HOME=~/FrameworkBenchmarks/installs/vert.x-1.3.1.final
-export VERTX_HOME=~/FrameworkBenchmarks/installs/vert.x-2.0.0-final
+export VERTX_HOME=~/FrameworkBenchmarks/installs/vert.x-2.0.2-final
 export GOROOT=~/FrameworkBenchmarks/installs/go
 export GOROOT=~/FrameworkBenchmarks/installs/go
 export GOPATH=~/FrameworkBenchmarks/go:~/FrameworkBenchmarks/webgo:~/FrameworkBenchmarks/revel
 export GOPATH=~/FrameworkBenchmarks/go:~/FrameworkBenchmarks/webgo:~/FrameworkBenchmarks/revel
 export TOMCAT_HOME=~/FrameworkBenchmarks/installs/apache-tomcat-7.0.35
 export TOMCAT_HOME=~/FrameworkBenchmarks/installs/apache-tomcat-7.0.35

+ 5 - 5
toolset/README.md

@@ -10,11 +10,11 @@ For deployment instructions, refer to the [Benchmark Suite Deployment README fil
 
 
 Assuming the deployment finished without error, we're ready to start the test suite. On the Linux server host, type:
 Assuming the deployment finished without error, we're ready to start the test suite. On the Linux server host, type:
 
 
-	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -i path-to-ssh-key --max-threads number-of-cores &
+	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -u username -i path-to-private-ssh-key --max-threads number-of-cores &
 
 
 For the number-of-cores parameter, you will need to know your application server's core count. For example, Amazon EC2 large instances have 2 cores.
 For the number-of-cores parameter, you will need to know your application server's core count. For example, Amazon EC2 large instances have 2 cores.
 
 
-`path-to-ssh-key` is the pathname of the private SSH key file of the Linux client's user. This file is set up during deployment.
+`path-to-private-ssh-key` is the pathname of the private SSH key file of the Linux client's user. This file is set up during deployment.  `username` is the username associated with the private SSH key.
 
 
 This script will run the full set of tests. Be aware that on Large instances, if you include the slower frameworks (and they are included by default), **the total runtime of a full suite of tests can be measured in days**, not just hours. The EC2 bill isn't going to break the bank, but it's also not going to be chump change.
 This script will run the full set of tests. Be aware that on Large instances, if you include the slower frameworks (and they are included by default), **the total runtime of a full suite of tests can be measured in days**, not just hours. The EC2 bill isn't going to break the bank, but it's also not going to be chump change.
 
 
@@ -30,11 +30,11 @@ To run the test suite on the Windows server, log on the server, open the PowerSh
 
 
 If you use a different configuration than two m1.large instances, please use the --name option to name the results appropriately.
 If you use a different configuration than two m1.large instances, please use the --name option to name the results appropriately.
 
 
-	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -i path-to-ssh-key --max-threads cores --name ec2-servertype-clienttype &
+	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -u username -i path-to-private-ssh-key --max-threads cores --name ec2-servertype-clienttype &
 
 
 So if you were running an m1.large and an m1.medium, it would look like this:
 So if you were running an m1.large and an m1.medium, it would look like this:
 
 
-	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -i path-to-ssh-key --max-threads cores --name ec2-m1.large-m1.medium &
+	nohup toolset/run-tests.py -s server-private-ip -c client-private-ip -u username -i path-to-private-ssh-key --max-threads cores --name ec2-m1.large-m1.medium &
 
 
 This will allow us to differentiate results.
 This will allow us to differentiate results.
 
 
@@ -42,7 +42,7 @@ This will allow us to differentiate results.
 
 
 If you are making changes to any of the tests, or you simply want to verify a single test, you can run the script with the --test flag. For example, if you only wanted to run the JRuby tests:
 If you are making changes to any of the tests, or you simply want to verify a single test, you can run the script with the --test flag. For example, if you only wanted to run the JRuby tests:
 
 
-	nohup toolset/run-tests.py -s server-ip -c client-ip -i path-to-ssh-key --max-threads cores --name unique-machine-name --test rack-jruby sinatra-jruby rails-jruby
+	nohup toolset/run-tests.py -s server-ip -c client-ip -u username -i path-to-private-ssh-key --max-threads cores --name unique-machine-name --test rack-jruby sinatra-jruby rails-jruby
 
 
 ## Result Files
 ## Result Files
 
 

+ 13 - 13
toolset/deployment/azure/azure-deployment.sh

@@ -217,19 +217,19 @@ function azure_save_deployment_configuration {
     echo "Saving configuration file at $AZURE_CONFIGURATION_OUTPUT_FILE"
     echo "Saving configuration file at $AZURE_CONFIGURATION_OUTPUT_FILE"
 
 
     cat >$AZURE_CONFIGURATION_OUTPUT_FILE <<_EOF_
     cat >$AZURE_CONFIGURATION_OUTPUT_FILE <<_EOF_
-BENCHMARK_LINUX_CLIENT=$CLIENT_VM_NAME.cloudapp.net
-BENCHMARK_LINUX_CLIENT_IP=$CLIENT_IP
-BENCHMARK_LINUX_SERVER=$LINUX_SERVER_VM_NAME.cloudapp.net
-BENCHMARK_LINUX_SERVER_IP=$LINUX_SERVER_IP
-BENCHMARK_LINUX_USER=$AZURE_LINUX_USER
-BENCHMARK_SSH_KEY=$AZURE_KEY_FILE
-BENCHMARK_WINDOWS_SERVER=$WINDOWS_SERVER_VM_NAME.cloudapp.net
-BENCHMARK_WINDOWS_SERVER_USER=$WINDOWS_SERVER_VM_NAME\Administrator
-BENCHMARK_SQL_SERVER=$SQL_SERVER_VM_NAME.cloudapp.net
-BENCHMARK_SQL_SERVER_USER=$SQL_SERVER_VM_NAME\Administrator
-BENCHMARK_WORKING_DIR=$BENCHMARK_WORKING_DIR
-BENCHMARK_REPOSITORY=$BENCHMARK_REPOSITORY
-BENCHMARK_BRANCH=$BENCHMARK_BRANCH
+BENCHMARK_LINUX_CLIENT="$CLIENT_VM_NAME.cloudapp.net"
+BENCHMARK_LINUX_CLIENT_IP="$CLIENT_IP"
+BENCHMARK_LINUX_SERVER="$LINUX_SERVER_VM_NAME.cloudapp.net"
+BENCHMARK_LINUX_SERVER_IP="$LINUX_SERVER_IP"
+BENCHMARK_LINUX_USER="$AZURE_LINUX_USER"
+BENCHMARK_SSH_KEY="$AZURE_KEY_FILE"
+BENCHMARK_WINDOWS_SERVER="$WINDOWS_SERVER_VM_NAME.cloudapp.net"
+BENCHMARK_WINDOWS_SERVER_USER="$WINDOWS_SERVER_VM_NAME\Administrator"
+BENCHMARK_SQL_SERVER="$SQL_SERVER_VM_NAME.cloudapp.net"
+BENCHMARK_SQL_SERVER_USER="$SQL_SERVER_VM_NAME\Administrator"
+BENCHMARK_WORKING_DIR="$BENCHMARK_WORKING_DIR"
+BENCHMARK_REPOSITORY="$BENCHMARK_REPOSITORY"
+BENCHMARK_BRANCH="$BENCHMARK_BRANCH"
 _EOF_
 _EOF_
 
 
     echo ""
     echo ""

+ 7 - 7
toolset/deployment/common/linux-initial-deployment.sh

@@ -22,19 +22,19 @@ information "Benchmark Suite Deployment: Linux server setup"
 information "******************************************************************************"
 information "******************************************************************************"
 
 
 BENCHMARK_REMOTE_CONFIGURATION_FILE="$BENCHMARK_WORKING_DIR/benchmark-configuration.sh"
 BENCHMARK_REMOTE_CONFIGURATION_FILE="$BENCHMARK_WORKING_DIR/benchmark-configuration.sh"
-BENCHMARK_REMOTE_KEY_FILE="~/.ssh/benchmark-key"
+BENCHMARK_REMOTE_KEY_FILE="/home/$BENCHMARK_LINUX_USER/.ssh/benchmark-key"
 
 
 # Create Linux host configuration script.
 # Create Linux host configuration script.
 echo ""
 echo ""
 echo "Creating Linux host configuration script at $BENCHMARK_REMOTE_CONFIGURATION_FILE"
 echo "Creating Linux host configuration script at $BENCHMARK_REMOTE_CONFIGURATION_FILE"
 cat >$BENCHMARK_REMOTE_CONFIGURATION_FILE <<_EOF_
 cat >$BENCHMARK_REMOTE_CONFIGURATION_FILE <<_EOF_
 #!/bin/bash
 #!/bin/bash
-export BENCHMARK_HOME=~/FrameworkBenchmarks
-export BENCHMARK_SERVER_IP=$BENCHMARK_LINUX_SERVER_IP
-export BENCHMARK_CLIENT_IP=$BENCHMARK_LINUX_CLIENT_IP
-export BENCHMARK_KEY_PATH=$BENCHMARK_REMOTE_KEY_FILE
-export BENCHMARK_REPOSITORY=$BENCHMARK_REPOSITORY
-export BENCHMARK_BRANCH=$BENCHMARK_BRANCH
+export BENCHMARK_HOME="/home/$BENCHMARK_LINUX_USER/FrameworkBenchmarks"
+export BENCHMARK_SERVER_IP="$BENCHMARK_LINUX_SERVER_IP"
+export BENCHMARK_CLIENT_IP="$BENCHMARK_LINUX_CLIENT_IP"
+export BENCHMARK_KEY_PATH="$BENCHMARK_REMOTE_KEY_FILE"
+export BENCHMARK_REPOSITORY="$BENCHMARK_REPOSITORY"
+export BENCHMARK_BRANCH="$BENCHMARK_BRANCH"
 _EOF_
 _EOF_
 
 
 # Upload Linux host configuration script.
 # Upload Linux host configuration script.

+ 1 - 1
toolset/setup/README.md

@@ -102,7 +102,7 @@ Now you can run tests:
 * Run a `Command Prompt` as Administrator.
 * Run a `Command Prompt` as Administrator.
 * Enter this command:
 * Enter this command:
 
 
-        powershell -ExecutionPolicy Bypass -Command "iex (New-Object Net.WebClient).DownloadString('https://raw.github.com/TechEmpower/FrameworkBenchmarks/master/setup-sqlserver-bootstrap.ps1')"
+        powershell -ExecutionPolicy Bypass -Command "iex (New-Object Net.WebClient).DownloadString('https://raw.github.com/TechEmpower/FrameworkBenchmarks/master/toolset/setup/sqlserver/setup-sqlserver-bootstrap.ps1')"
 
 
 * This will configure SQL Server, the Windows Firewall, and populate the database.
 * This will configure SQL Server, the Windows Firewall, and populate the database.
 
 

+ 11 - 11
toolset/setup/linux/installer.py

@@ -124,10 +124,10 @@ class Installer:
 
 
     self.__download("http://downloads.activestate.com/ActivePerl/releases/5.16.3.1603/ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz");
     self.__download("http://downloads.activestate.com/ActivePerl/releases/5.16.3.1603/ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz");
     self.__run_command("tar xzf ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz");
     self.__run_command("tar xzf ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746.tar.gz");
-    self.__run_command("sudo ./install.sh --license-accepted --prefix /opt/ActivePerl-5.16 --no-install-html", cwd="ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746", send_yes=True)
+    self.__run_command("sudo ./install.sh --license-accepted --prefix /opt/ActivePerl-5.16 --no-install-html", cwd="ActivePerl-5.16.3.1603-x86_64-linux-glibc-2.3.5-296746", send_yes=True, retry=True)
     self.__download("http://cpanmin.us", "cpanminus.pl")
     self.__download("http://cpanmin.us", "cpanminus.pl")
-    self.__run_command("perl cpanminus.pl --sudo App::cpanminus")
-    self.__run_command("cpanm -f -S DBI DBD::mysql Kelp Dancer Mojolicious Kelp::Module::JSON::XS Dancer::Plugin::Database Starman Plack JSON Web::Simple DBD::Pg JSON::XS EV HTTP::Parser::XS Monoceros EV IO::Socket::IP IO::Socket::SSL")
+    self.__run_command("perl cpanminus.pl --sudo App::cpanminus", retry=True)
+    self.__run_command("cpanm -f -S DBI DBD::mysql Kelp Dancer Mojolicious Kelp::Module::JSON::XS Dancer::Plugin::Database Starman Plack JSON Web::Simple DBD::Pg JSON::XS EV HTTP::Parser::XS Monoceros EV IO::Socket::IP IO::Socket::SSL", retry=True)
 
 
     #
     #
     # php
     # php
@@ -138,7 +138,7 @@ class Installer:
     self.__run_command("./configure --with-pdo-mysql --with-mysql --with-mcrypt --enable-intl --enable-mbstring --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-openssl", cwd="php-5.4.13")
     self.__run_command("./configure --with-pdo-mysql --with-mysql --with-mcrypt --enable-intl --enable-mbstring --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-openssl", cwd="php-5.4.13")
     self.__run_command("make", cwd="php-5.4.13")
     self.__run_command("make", cwd="php-5.4.13")
     self.__run_command("sudo make install", cwd="php-5.4.13")
     self.__run_command("sudo make install", cwd="php-5.4.13")
-    self.__run_command("printf \"\\n\" | sudo pecl install apc-beta", cwd="php-5.4.13")
+    self.__run_command("printf \"\\n\" | sudo pecl install apc-beta", cwd="php-5.4.13", retry=True)
     self.__run_command("sudo cp ../config/php.ini /usr/local/lib/php.ini")
     self.__run_command("sudo cp ../config/php.ini /usr/local/lib/php.ini")
     self.__run_command("sudo cp ../config/php-fpm.conf /usr/local/lib/php-fpm.conf")
     self.__run_command("sudo cp ../config/php-fpm.conf /usr/local/lib/php-fpm.conf")
     self.__run_command("rm php-5.4.13.tar.gz")
     self.__run_command("rm php-5.4.13.tar.gz")
@@ -283,14 +283,14 @@ class Installer:
     #
     #
     # Vert.x
     # Vert.x
     #
     #
-    self.__download("http://dl.bintray.com/vertx/downloads/vert.x-2.0.0-final.tar.gz")
-    self.__run_command("tar xzf vert.x-2.0.0-final.tar.gz")
+    self.__download("http://dl.bintray.com/vertx/downloads/vert.x-2.0.2-final.tar.gz?direct=true")
+    self.__run_command("tar xzf vert.x-2.0.2-final.tar.gz")
 
 
     #
     #
     # Yesod
     # Yesod
     #
     #
-    self.__run_command("cabal update")
-    self.__run_command("cabal install yesod persistent-mysql")
+    self.__run_command("cabal update", retry=True)
+    self.__run_command("cabal install yesod persistent-mysql", retry=True)
 
 
     #
     #
     # Jester
     # Jester
@@ -309,9 +309,9 @@ class Installer:
     python3_bin= "~/FrameworkBenchmarks/installs/py3/bin"
     python3_bin= "~/FrameworkBenchmarks/installs/py3/bin"
     def easy_install(pkg, two=True, three=False, pypy=False):
     def easy_install(pkg, two=True, three=False, pypy=False):
       cmd = "/easy_install -ZU '" + pkg + "'"
       cmd = "/easy_install -ZU '" + pkg + "'"
-      if two:   self.__run_command(python_bin + cmd)
-      if three: self.__run_command(python3_bin + cmd)
-      if pypy:  self.__run_command(pypy_bin + cmd)
+      if two:   self.__run_command(python_bin + cmd, retry=True)
+      if three: self.__run_command(python3_bin + cmd, retry=True)
+      if pypy:  self.__run_command(pypy_bin + cmd, retry=True)
 
 
     self.__download("http://bitbucket.org/pypy/pypy/downloads/pypy-2.1-linux64.tar.bz2")
     self.__download("http://bitbucket.org/pypy/pypy/downloads/pypy-2.1-linux64.tar.bz2")
     self.__run_command("tar xjf pypy-2.1-linux64.tar.bz2")
     self.__run_command("tar xjf pypy-2.1-linux64.tar.bz2")

+ 2 - 2
toolset/setup/sqlserver/setup-sqlserver-bootstrap.ps1

@@ -1,13 +1,13 @@
 # To download and run this script, open an elevated Command Prompt and then run:
 # To download and run this script, open an elevated Command Prompt and then run:
 #
 #
-# powershell -ExecutionPolicy Bypass -Command "iex (New-Object Net.WebClient).DownloadString('https://raw.github.com/TechEmpower/FrameworkBenchmarks/master/setup-sqlserver-bootstrap.ps1')"
+# powershell -ExecutionPolicy Bypass -Command "iex (New-Object Net.WebClient).DownloadString('https://raw.github.com/TechEmpower/FrameworkBenchmarks/master/toolset/setup/sqlserver/setup-sqlserver-bootstrap.ps1')"
 
 
 $basedir = "C:\FrameworkBenchmarks"
 $basedir = "C:\FrameworkBenchmarks"
 $rawRepo = "https://raw.github.com/TechEmpower/FrameworkBenchmarks/master"
 $rawRepo = "https://raw.github.com/TechEmpower/FrameworkBenchmarks/master"
 
 
 $config_url = $rawRepo + "/config"
 $config_url = $rawRepo + "/config"
 $config_local = $basedir + "\config"
 $config_local = $basedir + "\config"
-$setup_sqlserver_url = $rawRepo + "/setup-sqlserver.ps1"
+$setup_sqlserver_url = $rawRepo + "/toolset/setup/sqlserver/setup-sqlserver.ps1"
 $setup_sqlserver_local = $basedir + "\setup-sqlserver.ps1"
 $setup_sqlserver_local = $basedir + "\setup-sqlserver.ps1"
 $create_sqlserver_login_and_database_url = $config_url + "/create-sqlserver-login-and-database.sql"
 $create_sqlserver_login_and_database_url = $config_url + "/create-sqlserver-login-and-database.sql"
 $create_sqlserver_login_and_database_local = $config_local + "/create-sqlserver-login-and-database.sql"
 $create_sqlserver_login_and_database_local = $config_local + "/create-sqlserver-login-and-database.sql"

+ 1 - 1
toolset/setup/windows/installer-bootstrap.ps1

@@ -10,7 +10,7 @@ $basedir = "C:\FrameworkBenchmarks"
 $workdir = $basedir + "\installs"
 $workdir = $basedir + "\installs"
 
 
 $repo = "https://github.com/TechEmpower/FrameworkBenchmarks"
 $repo = "https://github.com/TechEmpower/FrameworkBenchmarks"
-$installer = $basedir + "\installer.ps1"
+$installer = $basedir + "\toolset\setup\windows\installer.ps1"
 
 
 $git = "C:\Git\bin\git.exe"
 $git = "C:\Git\bin\git.exe"
 $gitinstaller_file = "Git-1.8.1.2-preview20130201.exe"
 $gitinstaller_file = "Git-1.8.1.2-preview20130201.exe"

+ 0 - 32
vertx/App.groovy

@@ -1,32 +0,0 @@
-// Our application config
-
-def persistorConf = [
-  address: 'hello.persistor',
-  db_name: 'hello_world',
-  host: '127.0.0.1'
-]
-
-def permitted =
-[
-  // Allow calls to get static album data from the persistor
-  //[
-  //  'address' : 'hello.persistor',
-  //  'match' : [
-  //    'action' : 'find',
-  //    'collection' : 'users'
-  //  ]
-  //]
-  [
-    'address' : 'hello.persistor'
-  ]
-]
-
-container.with {
-
-  // Deploy the busmods
-  // deployModule('vertx.mongo-persistor-v1.2.1', persistorConf, 8)
-
-  // Start the web server
-
-  deployVerticle('WebServer', ['permitted': permitted], 8)
-}

+ 63 - 95
vertx/WebServer.java

@@ -1,143 +1,111 @@
-import java.io.IOException;
 import java.nio.charset.*;
 import java.nio.charset.*;
+
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 import java.util.Random;
 import java.util.Random;
-import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
 import org.vertx.java.core.Handler;
 import org.vertx.java.core.Handler;
 import org.vertx.java.core.buffer.Buffer;
 import org.vertx.java.core.buffer.Buffer;
 import org.vertx.java.core.eventbus.Message;
 import org.vertx.java.core.eventbus.Message;
 import org.vertx.java.core.http.HttpServerRequest;
 import org.vertx.java.core.http.HttpServerRequest;
-import org.vertx.java.core.json.JsonArray;
 import org.vertx.java.core.json.JsonObject;
 import org.vertx.java.core.json.JsonObject;
+import org.vertx.java.core.json.impl.Json;
 import org.vertx.java.platform.Verticle;
 import org.vertx.java.platform.Verticle;
 
 
-public class WebServer
-	extends    Verticle
-	implements Handler<HttpServerRequest>
-{
-  private final ObjectMapper mapper = new ObjectMapper();
+public class WebServer extends Verticle implements Handler<HttpServerRequest> {
+
+  private static String helloWorld = "Hello, World!";
+  private static Buffer helloWorldBuffer = new Buffer(helloWorld);
+  private static String helloWorldContentLength = String.valueOf(helloWorldBuffer.length());
 
 
   @Override
   @Override
-  public void start()
-  {
-    this.getVertx().createHttpServer().requestHandler(this).listen(8080);
+  public void start() {
+    vertx.createHttpServer().requestHandler(WebServer.this).listen(8080);
   }
   }
 
 
   @Override
   @Override
-  public void handle(HttpServerRequest req)
-  {
-    if (req.path().equals("/json"))
-    {
-      handleJson(req);
-    }
-    else if (req.path().equals("/db"))
-    {
-      handleDb(req);
+  public void handle(HttpServerRequest req) {
+    String path = req.path();
+    switch (path.charAt(1)) {
+      case 'p':
+        handlePlainText(req);
+        break;
+      case 'j':
+        handleJson(req);
+        break;
+      case 'd':
+        handleDbMongo(req);
+        break;
+      default:
+        req.response().setStatusCode(404);
+        req.response().end();
     }
     }
-    else
-    {
-      req.response().setStatusCode(404);
-      req.response().end();
-    }
-  }
 
 
+  }
 
 
-  private void handleJson(HttpServerRequest req)
-  {
-    Buffer buffer;
-    try
-    {
-      Map<String, String> data = new HashMap<String, String>();
-      data.put("message", "Hello, world");
-      buffer = new Buffer(mapper.writeValueAsBytes(data));
-    }
-    catch (IOException e)
-    {
-      req.response().setStatusCode(500);
-      req.response().end();
-      return;
-    }
-    
+  private void handlePlainText(HttpServerRequest req) {
+    req.response().putHeader("Content-Type", "application/json; charset=UTF-8");
+    req.response().putHeader("Content-Length", helloWorldContentLength);
+    req.response().end(helloWorldBuffer);
+  }
 
 
+  private void handleJson(HttpServerRequest req) {
+    String result = Json.encode(Collections.singletonMap("message", "Hello, world!"));
+    int contentLength = result.getBytes(StandardCharsets.UTF_8).length;
     req.response().putHeader("Content-Type", "application/json; charset=UTF-8");
     req.response().putHeader("Content-Type", "application/json; charset=UTF-8");
-    req.response().putHeader("Content-Length", Integer.toString(buffer.length()));
-    req.response().write(buffer);
-    req.response().end();
+    req.response().putHeader("Content-Length", String.valueOf(contentLength));
+    req.response().end(result);
   }
   }
 
 
-  private void handleDb(final HttpServerRequest req)
-  {
+  private void handleDbMongo(final HttpServerRequest req) {
     int queriesParam = 1;
     int queriesParam = 1;
-    try 
-    {
+    try {
       queriesParam = Integer.parseInt(req.params().get("queries"));
       queriesParam = Integer.parseInt(req.params().get("queries"));
-    }
-    catch (NumberFormatException e)
-    {
+    } catch (NumberFormatException e) {
       // do nothing
       // do nothing
     }
     }
 
 
-    final DbHandler dbh = new DbHandler(req, queriesParam);
+    final MongoHandler dbh = new MongoHandler(req, queriesParam);
     final Random random = ThreadLocalRandom.current();
     final Random random = ThreadLocalRandom.current();
 
 
-    for (int i = 0; i < queriesParam; i++)
-    {
-      this.getVertx().eventBus().send(
-        "hello.persistor",
-        new JsonObject()
-            .putString("action", "findone")
-            .putString("collection", "world")
-            .putObject("matcher", new JsonObject().putNumber("id", (random.nextInt(10000) + 1))),
-        dbh);
+    for (int i = 0; i < queriesParam; i++) {
+      vertx.eventBus().send(
+          "hello.persistor",
+          new JsonObject()
+              .putString("action", "findone")
+              .putString("collection", "world")
+              .putObject("matcher", new JsonObject().putNumber("id", (random.nextInt(10000) + 1))),
+          dbh);
     }
     }
   }
   }
 
 
-  class DbHandler implements Handler<Message<JsonObject>>
-  {
+  private static class MongoHandler implements Handler<Message<JsonObject>> {
     private final HttpServerRequest req;
     private final HttpServerRequest req;
     private final int queries;
     private final int queries;
-    private final List<Object> worlds = new CopyOnWriteArrayList<>();
+    private final List<Object> worlds = new ArrayList<>();
 
 
-    public DbHandler(HttpServerRequest request, int queriesParam)
-    {
-   	  this.req = request;
+    public MongoHandler(HttpServerRequest request, int queriesParam) {
+      this.req = request;
       this.queries = queriesParam;
       this.queries = queriesParam;
     }
     }
 
 
     @Override
     @Override
-    public void handle(Message<JsonObject> reply)
-    {
+    public void handle(Message<JsonObject> reply) {
       final JsonObject body = reply.body();
       final JsonObject body = reply.body();
 
 
-      if ("ok".equals(body.getString("status")))
-      {
-      	this.worlds.add(body.getObject("result"));
-      }
-
-      if (this.worlds.size() == this.queries)
-      {
-        // All queries have completed; send the response.
-        // final JsonArray arr = new JsonArray(worlds);
-        try
-        {
-          final String result = mapper.writeValueAsString(worlds);
+      if ("ok".equals(body.getString("status"))) {
+        this.worlds.add(body.getObject("result"));
+        if (this.worlds.size() == this.queries) {
+          // All queries have completed; send the response.
+          final String result = Json.encode(worlds);
           final int contentLength = result.getBytes(StandardCharsets.UTF_8).length;
           final int contentLength = result.getBytes(StandardCharsets.UTF_8).length;
           this.req.response().putHeader("Content-Type", "application/json; charset=UTF-8");
           this.req.response().putHeader("Content-Type", "application/json; charset=UTF-8");
-          this.req.response().putHeader("Content-Length", Integer.toString(contentLength));
-          this.req.response().write(result);
-          this.req.response().end();
-        }
-        catch (IOException e)
-        {
-          req.response().setStatusCode(500);
-          req.response().end();
+          this.req.response().putHeader("Content-Length", String.valueOf(contentLength));
+          this.req.response().end(result);
         }
         }
+      } else {
+        System.err.println("Failed to execute query");
       }
       }
     }
     }
   }
   }

+ 15 - 0
vertx/app.js

@@ -0,0 +1,15 @@
+var container = require('vertx/container')
+
+var persistorConf = {
+  address: 'hello.persistor',
+  db_name: 'hello_world',
+  host: 'localhost'
+}
+
+container.deployModule('io.vertx~mod-mongo-persistor~2.0.0-final', persistorConf, function (err, dep_id) {
+  if (!err) {
+    container.deployVerticle('WebServer.java', 8);
+  } else {
+    err.printStackTrace();
+  }
+});

+ 5 - 4
vertx/benchmark_config

@@ -3,9 +3,10 @@
   "tests": [{
   "tests": [{
     "default": {
     "default": {
       "setup_file": "setup",
       "setup_file": "setup",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/db?queries=",
+      "json_url": "/j",
+      "db_url": "/d",
+      "plaintext_url": "/p",
+      "query_url": "/d?queries=",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Platform",
       "classification": "Platform",
@@ -22,4 +23,4 @@
       "versus": "netty"
       "versus": "netty"
     }
     }
   }]
   }]
-}
+}

BIN
vertx/extra-jars-for-vertx-home/guava-11.0.2.jar


BIN
vertx/extra-jars-for-vertx-home/mustache.jar


+ 4 - 5
vertx/setup.py

@@ -7,10 +7,9 @@ import os
 nCpu = multiprocessing.cpu_count()
 nCpu = multiprocessing.cpu_count()
 
 
 def start(args):
 def start(args):
-  setup_util.replace_text("vertx/App.groovy", "host: '.*'", "host: '" + args.database_host + "'")
-
-  try:    
-    subprocess.Popen("vertx run WebServer.java -instances " + str(nCpu) , shell=True, cwd="vertx")
+  setup_util.replace_text("vertx/app.js", "host: '.*'", "host: '" + args.database_host + "'")
+  try:
+    subprocess.Popen("vertx run app.js", shell=True, cwd="vertx")
     return 0
     return 0
   except subprocess.CalledProcessError:
   except subprocess.CalledProcessError:
     return 1
     return 1
@@ -18,7 +17,7 @@ def stop():
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   out, err = p.communicate()
   out, err = p.communicate()
   for line in out.splitlines():
   for line in out.splitlines():
-    if 'App.groovy' in line:
+    if 'app.js' in line:
       pid = int(line.split(None, 2)[1])
       pid = int(line.split(None, 2)[1])
       os.kill(pid, 9)
       os.kill(pid, 9)