Browse Source

Merge branch 'master' of github-msmith:TechEmpower/FrameworkBenchmarks

msmith-techempower 10 years ago
parent
commit
3c7800a4c2

+ 1 - 0
.travis.yml

@@ -38,6 +38,7 @@ env:
     - "TESTDIR=Clojure/aleph"
     - "TESTDIR=Clojure/aleph"
     - "TESTDIR=Crystal/crystal-raw"
     - "TESTDIR=Crystal/crystal-raw"
     - "TESTDIR=Crystal/moonshine"
     - "TESTDIR=Crystal/moonshine"
+    - "TESTDIR=D/vibed"
     - "TESTDIR=Dart/dart"
     - "TESTDIR=Dart/dart"
     - "TESTDIR=Dart/dart-redstone"
     - "TESTDIR=Dart/dart-redstone"
     - "TESTDIR=Dart/dart-start"
     - "TESTDIR=Dart/dart-start"

+ 7 - 0
frameworks/D/vibed/.gitignore

@@ -0,0 +1,7 @@
+.dub
+docs.json
+__dummy.html
+*.o
+*.obj
+*.dll
+*.exe

+ 34 - 0
frameworks/D/vibed/README.md

@@ -0,0 +1,34 @@
+# Vibe.D Benchmarking Test
+
+This is the Vibe.D portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+
+* [JSON test controller/view](source/app.d)
+
+### Data-Store/Database Mapping Test
+
+* [DB test controller/model](source/app.d)
+
+## Infrastructure Software Versions
+The tests were run with:
+* [Vibe.D v0.7.19](http://vibed.org/)
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost:8080/json
+
+### Plaintext Test
+
+http://localhost:8080/plaintext
+
+### Data-Store/Database Mapping Test
+
+MongoRaw:
+http://localhost:8080/db
+
+### Variable Query Test
+
+MongoDB Raw:
+http://localhost:8080/queries?queries=5

+ 26 - 0
frameworks/D/vibed/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "vibed",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MongoDB",
+      "framework": "vibed",
+      "language": "D",
+      "orm": "Raw",
+      "platform": "D",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Vibe.D",
+      "notes": "",
+      "versus": "vibed"
+    }
+  }]
+}

+ 10 - 0
frameworks/D/vibed/dub.json

@@ -0,0 +1,10 @@
+{
+  "name": "fwb",
+  "description": "A simple vibe.d server application.",
+  "copyright": "Copyright © 2015, jin",
+  "authors": ["jin"],
+  "dependencies": {
+    "vibe-d": "~>0.7.19"
+  },
+  "versions": ["VibeDefaultMain"]
+}

+ 11 - 0
frameworks/D/vibed/dub.selections.json

@@ -0,0 +1,11 @@
+{
+  "fileVersion": 1,
+  "versions": {
+    "memutils": "0.3.5",
+    "vibe-d": "0.7.23",
+    "libevent": "2.0.1+2.0.16",
+    "openssl": "1.1.4+1.0.1g",
+    "libev": "5.0.0+4.04",
+    "libasync": "0.7.1"
+  }
+}

+ 3 - 0
frameworks/D/vibed/install.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+fw_depends dlang dub

+ 14 - 0
frameworks/D/vibed/setup.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+source $IROOT/dlang.installed
+source $IROOT/dub.installed
+
+sed -i 's|127.0.0.1|'"${DBHOST}"'|g' source/app.d
+
+# Clean any files from last run
+rm -f fwb
+rm -rf .dub
+
+dub build --force
+
+./fwb &

+ 102 - 0
frameworks/D/vibed/source/app.d

@@ -0,0 +1,102 @@
+import vibe.appmain;
+import vibe.d;
+import std.random;
+
+const worldSize = 10000;
+const fortunesSize = 100;
+const mongoUrl = "mongodb://127.0.0.1/";
+
+MongoClient mongo;
+MongoCollection worldCollection;
+MongoCollection fortunesCollection;
+
+shared static this()
+{
+  mongo = connectMongoDB( mongoUrl );
+  worldCollection = mongo.getCollection( "hello_world.World" );
+  fortunesCollection = mongo.getCollection( "hello_world.Fortunes" );
+
+  auto router = new URLRouter;
+  router.get("/plaintext", &plaintext);
+  router.get("/json", &json);
+  router.get("/db", &db);
+  router.get("/queries", &queries);
+  router.get("/generate-world", &generateWorld);
+  router.get("/generate-fortunes", &generateFortunes);
+  router.get("/", staticTemplate!"index.dt");
+
+  auto settings = new HTTPServerSettings;
+  settings.port = 8080;
+
+  listenHTTP(settings, router);
+}
+
+void json(HTTPServerRequest req, HTTPServerResponse res)
+{
+  auto helloWorld  = Json([
+    "message" : *new Json( "Hello, World!" )
+  ]);
+  res.writeJsonBody( helloWorld );
+}
+
+void generateWorld(HTTPServerRequest req, HTTPServerResponse res)
+{
+  try {
+    worldCollection.drop();
+  } catch( Exception error ) {}
+  for( auto i = 0 ; i < worldSize ; ++i ) {
+    worldCollection.insert([
+      "_id": i + 1,
+      "randomNumber": uniform( 0 , worldSize )
+    ]);
+  }
+  res.writeBody( "Generated" );
+}
+
+void generateFortunes(HTTPServerRequest req, HTTPServerResponse res)
+{
+  try {
+    fortunesCollection.drop();
+  } catch( Exception error ) {}
+  for( uint i = 0 ; i < worldSize ; ++i ) {
+    fortunesCollection.insert([
+      "_id": new Bson( i + 1 ),
+      "message": new Bson( to!string( uniform( 0 , fortunesSize ) ) )
+    ]);
+  }
+  res.writeBody( "Generated" );
+}
+
+void db(HTTPServerRequest req, HTTPServerResponse res)
+{
+  auto data = worldCollection.findOne([
+    "_id": uniform( 1 , worldSize + 1 )
+  ]); 
+  res.writeJsonBody( data );
+}
+
+void queries(HTTPServerRequest req, HTTPServerResponse res)
+{
+  auto count = 1;
+  try {
+    count = to!uint( req.query["queries"] );
+    if( !count ) {
+      count = 1;
+    } else if( count > 500 ) {
+      count = 500;
+    }
+  } catch( Exception error ) { }
+  
+  auto data = new Bson[ count ];
+  for( uint i = 0 ; i < count ; ++i ) {
+    data[i] = worldCollection.findOne([
+      "_id": uniform( 1 , worldSize + 1 )
+    ]);
+  }
+  res.writeJsonBody( data );
+}
+
+void plaintext(HTTPServerRequest req, HTTPServerResponse res)
+{
+  res.writeBody("Hello, World!");
+}

+ 19 - 0
frameworks/D/vibed/views/index.dt

@@ -0,0 +1,19 @@
+doctype html
+html
+  head
+    style a { display: block }
+  body
+    ul
+      li
+        a(href="/generate-world") generate world
+      li
+        a(href="/generate-fortunes") generate fortunes
+    ol
+      li
+        a(href="/json") json stringify
+      li
+        a(href="/db") single query
+      li
+        a(href="/queries?queries=5") multiple queries
+      li
+        a(href="/plaintext") plain text

+ 10 - 5
frameworks/Java/rapidoid/pom.xml

@@ -18,11 +18,16 @@
             <artifactId>rapidoid-http</artifactId>
             <artifactId>rapidoid-http</artifactId>
             <version>3.0.0</version>
             <version>3.0.0</version>
         </dependency>
         </dependency>
-        <dependency>
-            <groupId>org.rapidoid</groupId>
-            <artifactId>rapidoid-json</artifactId>
-            <version>3.0.0</version>
-        </dependency>
+	<dependency>
+		<groupId>com.fasterxml.jackson.core</groupId>
+		<artifactId>jackson-databind</artifactId>
+		<version>2.6.0-rc2</version>
+	</dependency>
+	<dependency>
+		<groupId>com.fasterxml.jackson.module</groupId>
+		<artifactId>jackson-module-afterburner</artifactId>
+		<version>2.6.0-rc2</version>
+	</dependency>
     </dependencies>
     </dependencies>
 
 
 	<build>
 	<build>

+ 17 - 1
frameworks/Java/rapidoid/src/main/java/hello/SimpleHttpProtocol.java

@@ -31,6 +31,9 @@ import org.rapidoid.net.impl.RapidoidHelper;
 import org.rapidoid.util.Dates;
 import org.rapidoid.util.Dates;
 import org.rapidoid.wrap.BoolWrap;
 import org.rapidoid.wrap.BoolWrap;
 
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
+
 public class SimpleHttpProtocol implements Protocol {
 public class SimpleHttpProtocol implements Protocol {
 
 
 	private static final byte[] HTTP_200_OK = "HTTP/1.1 200 OK\r\n".getBytes();
 	private static final byte[] HTTP_200_OK = "HTTP/1.1 200 OK\r\n".getBytes();
@@ -70,6 +73,14 @@ public class SimpleHttpProtocol implements Protocol {
 
 
 	private static final HttpParser HTTP_PARSER = new HttpParser();
 	private static final HttpParser HTTP_PARSER = new HttpParser();
 
 
+	public static final ObjectMapper MAPPER = mapper();
+
+	private static ObjectMapper mapper() {
+		ObjectMapper mapper = new ObjectMapper();
+		mapper.registerModule(new AfterburnerModule());
+		return mapper;
+	}
+
 	public void process(Channel ctx) {
 	public void process(Channel ctx) {
 		if (ctx.isInitial()) {
 		if (ctx.isInitial()) {
 			return;
 			return;
@@ -153,7 +164,12 @@ public class SimpleHttpProtocol implements Protocol {
 
 
 		int posBefore = output.size();
 		int posBefore = output.size();
 
 
-		ctx.writeJSON(new Message("Hello, World!"));
+		Message msg = new Message("Hello, World!");
+		try {
+			MAPPER.writeValue(output.asOutputStream(), msg);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
 
 
 		int posAfter = output.size();
 		int posAfter = output.size();
 		output.putNumAsText(posConLen, posAfter - posBefore, false);
 		output.putNumAsText(posConLen, posAfter - posBefore, false);

+ 2 - 2
frameworks/Lua/lapis/setup.sh

@@ -4,7 +4,7 @@ sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' config.lua
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' config.moon
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' config.moon
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' nginx.conf
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' nginx.conf
 
 
-export LAPIS_OPENRESTY=${IROOT}/openresty-1.7.7.1
+export LAPIS_OPENRESTY=${IROOT}/openresty-1.7.10.1
 export PATH=${LAPIS_OPENRESTY}/nginx/sbin:$PATH
 export PATH=${LAPIS_OPENRESTY}/nginx/sbin:$PATH
 
 
-lapis server production &
+lapis server production &

+ 2 - 2
frameworks/Lua/openresty/setup.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 #!/bin/bash
-export OPENRESTY_HOME=${IROOT}/openresty-1.7.7.1
+export OPENRESTY_HOME=${IROOT}/openresty-1.7.10.1
 
 
 sed -i 's|CWD|'"${TROOT}"'|g' nginx.conf
 sed -i 's|CWD|'"${TROOT}"'|g' nginx.conf
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' app.lua
 sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' app.lua
 
 
-${OPENRESTY_HOME}/nginx/sbin/nginx -c $TROOT/nginx.conf -g "worker_processes '"${MAX_THREADS}"';" &
+${OPENRESTY_HOME}/nginx/sbin/nginx -c $TROOT/nginx.conf -g "worker_processes '"${MAX_THREADS}"';" &

+ 9 - 15
frameworks/Python/web2py/app/app/models/db.py

@@ -17,24 +17,18 @@ myconf = AppConfig(reload=True)
 DATABASE = None
 DATABASE = None
 DATABASE_URI = "mysql://benchmarkdbuser:benchmarkdbpass@localhost:3306/hello_world"
 DATABASE_URI = "mysql://benchmarkdbuser:benchmarkdbpass@localhost:3306/hello_world"
 
 
-if not request.env.web2py_runtime_gae:
-    ## if NOT running on Google App Engine use SQLite or other DB
-    db = DAL(DATABASE_URI, fake_migrate_all=True)
-    DATABASE = db
-else:
-    ## connect to Google BigTable (optional 'google:datastore://namespace')
-    db = DAL(DATABASE_URI, fake_migrate_all=True)
-    DATABASE = db
-    ## store sessions and tickets there
-    session.connect(request, response, db=db)
-    ## or store session in Memcache, Redis, etc.
-    ## from gluon.contrib.memdb import MEMDB
-    ## from google.appengine.api.memcache import Client
-    ## session.connect(request, response, db = MEMDB(Client()))
+db = DAL(DATABASE_URI, fake_migrate_all=True)
+DATABASE = db
+## store sessions and tickets there
+##session.connect(request, response, db=db)
+## or store session in Memcache, Redis, etc.
+## from gluon.contrib.memdb import MEMDB
+## from google.appengine.api.memcache import Client
+## session.connect(request, response, db = MEMDB(Client()))
 
 
 ## by default give a view/generic.extension to all actions from localhost
 ## by default give a view/generic.extension to all actions from localhost
 ## none otherwise. a pattern can be 'controller/function.extension'
 ## none otherwise. a pattern can be 'controller/function.extension'
-response.generic_patterns = ['*'] if request.is_local else []
+response.generic_patterns = [] 
 
 
 db.define_table("world",
 db.define_table("world",
     Field("id"),
     Field("id"),

+ 26 - 0
toolset/setup/linux/languages/dlang.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+DLANG=$IROOT/dlang
+RETCODE=$(fw_exists ${DLANG}.installed)
+[ ! "$RETCODE" == 0 ] || { \
+  source $DLANG.installed
+  return 0; }
+
+mkdir -p $DLANG
+fw_get http://downloads.dlang.org/releases/2.x/2.067.1/dmd_2.067.1-0_amd64.deb
+dpkg-deb -x dmd_2.067.1-0_amd64.deb $DLANG
+
+# According to this file (dmd.conf) dmd will, upon execution, look for
+# a dmd.conf in 1) the current working directory [bad], 2) the directory
+# specified by the HOME environment variable [bad], 3) the directory in
+# which dmd resides [less bad], and 4) the /etc directory.
+# We are trying to maintain as little global presence as possible, so
+# we need to change the DFLAGS in the dmd.conf to be correctly sandboxed
+# to the $DLANG folder (in IROOT).
+cp $DLANG/etc/dmd.conf $DLANG/usr/bin
+sed -i "s|-I/usr/|-I${DLANG}/usr/|g" $DLANG/usr/bin/dmd.conf
+sed -i "s|-L/usr/|-L${DLANG}/usr/|g" $DLANG/usr/bin/dmd.conf
+
+echo -e "export PATH=${DLANG}/usr/bin:\$PATH" > $DLANG.installed
+
+source $DLANG.installed

+ 2 - 1
toolset/setup/linux/prerequisites.sh

@@ -44,7 +44,8 @@ sudo apt-get -qqy install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options:
   cloc dstat                        `# Collect resource usage statistics` \
   cloc dstat                        `# Collect resource usage statistics` \
   libsasl2-dev                      `# Needed by mgo for go-mongodb test` \
   libsasl2-dev                      `# Needed by mgo for go-mongodb test` \
   llvm-dev                          `# Required for correct Ruby installation` \
   llvm-dev                          `# Required for correct Ruby installation` \
-  libboost-dev                      `# Silicon relies on boost::lexical_cast.`
+  libboost-dev                      `# Silicon relies on boost::lexical_cast.` \
+  xdg-utils                         `# Needed by dlang.`
 
 
 # Install gcc-4.8 and gcc-4.9
 # Install gcc-4.8 and gcc-4.9
 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y

+ 16 - 0
toolset/setup/linux/systools/dub.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+DUB=$IROOT/dub
+RETCODE=$(fw_exists ${DUB}.installed)
+[ ! "$RETCODE" == 0 ] || { \
+  source $DUB.installed
+  return 0; }
+
+mkdir dub
+cd dub
+fw_get http://code.dlang.org/files/dub-0.9.23-linux-x86_64.tar.gz
+fw_untar dub-0.9.23-linux-x86_64.tar.gz
+
+echo -e "export PATH=${DUB}:\$PATH" > $DUB.installed
+
+source $DUB.installed

+ 6 - 6
toolset/setup/linux/webservers/openresty.sh

@@ -1,16 +1,16 @@
 #!/bin/bash
 #!/bin/bash
 
 
-RETCODE=$(fw_exists ${IROOT}/openresty-1.7.7.1.installed)
+RETCODE=$(fw_exists ${IROOT}/openresty-1.7.10.1.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 
 fw_depends nginx lua
 fw_depends nginx lua
 
 
-fw_get http://openresty.org/download/ngx_openresty-1.7.7.1.tar.gz
-fw_untar ngx_openresty-1.7.7.1.tar.gz
+fw_get http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz
+fw_untar ngx_openresty-1.7.10.1.tar.gz
 
 
-cd ngx_openresty-1.7.7.1
-./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-http_postgres_module --prefix=${IROOT}/openresty-1.7.7.1 -j4
+cd ngx_openresty-1.7.10.1
+./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-http_postgres_module --prefix=${IROOT}/openresty-1.7.10.1 -j4
 make -j4
 make -j4
 make install
 make install
 
 
-touch ${IROOT}/openresty-1.7.7.1.installed
+touch ${IROOT}/openresty-1.7.10.1.installed