Browse Source

Merge branch 'vibed' of https://github.com/nin-jin/FrameworkBenchmarks into vibed

Conflicts:
	frameworks/Python/historical/webware/app/Context/AFortune.py
msmith-techempower 10 years ago
parent
commit
09f9f542ff

+ 1 - 0
.travis.yml

@@ -35,6 +35,7 @@ env:
     - "TESTDIR=Clojure/luminus"
     - "TESTDIR=Clojure/luminus"
     - "TESTDIR=Clojure/pedestal"
     - "TESTDIR=Clojure/pedestal"
     - "TESTDIR=Clojure/aleph"
     - "TESTDIR=Clojure/aleph"
+    - "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

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

@@ -0,0 +1,25 @@
+{
+  "framework": "vibed",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "update_url": "/update?queries=",
+      "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"
+	}
+}

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

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
+sudo apt-get update && sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring && sudo apt-get update
+sudo apt-get install -qq -y dub dmd-bin
+sudo apt-get install -qq -y libevent-dev libssl-dev
+sudo apt-get install -qq -y g++ gcc-multilib xdg-utils
+cd $FWROOT/frameworks/D/vibed
+dub build --build-mode=singleFile

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

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+fw_depends dlang dub
+
+sed -i 's|127.0.0.1|'"${DBHOST}"'|g' source/app.d
+
+dub build --build-mode=singleFile
+
+./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

+ 1 - 1
frameworks/Python/historical/webware/app/Context/AFortune.py

@@ -11,4 +11,4 @@ class AFortune(Database.Base):
         return {
         return {
             'id': self.id,
             'id': self.id,
             'randomNumber': self.randomNumber,
             'randomNumber': self.randomNumber,
-        }
+        }

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

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+DLANG=$IROOT/dlang
+RETCODE=$(fw_exists ${DLANG}.installed)
+[ ! "$RETCODE" == 0 ] || { \
+  source $DLANG.installed
+  return 0; }
+
+fw_get http://downloads.dlang.org/releases/2.x/2.067.1/dmd_2.067.1-0_amd64.deb
+dpkg -i dmd_2.067.1-0_amd64.deb --instdir=$DLANG
+
+echo -e "export PATH=${DLANG}:\$PATH" > $DLANG.installed
+
+source $DLANG.installed

+ 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