Browse Source

Benchmark for the Valum framework (#2762)

* Benchmark for the Valum framework

Minimally implements the '/plaintext' and '/json' endpoints.

JSON-based benchmarks are implemented with 'json-glib-1.0'.

Include setup for the following tools:

 - meson
 - ninja
 - vala

* Use a specific version of Meson for reproducibility

* Add a README.md for describing Valum

* valum: Use 'GLib' instead of 'VSGI' for the platform
Guillaume Poirier-Morency 8 years ago
parent
commit
ed35cf8482

+ 1 - 0
.travis.yml

@@ -195,6 +195,7 @@ env:
     - "TESTDIR=Scala/finch"
     - "TESTDIR=Scala/finch"
     - "TESTDIR=Swift/vapor"
     - "TESTDIR=Swift/vapor"
     - "TESTDIR=Ur/urweb"
     - "TESTDIR=Ur/urweb"
+    - "TESTDIR=Vala/valum"
 
 
 before_script:
 before_script:
 
 

+ 20 - 0
frameworks/Vala/valum/README.md

@@ -0,0 +1,20 @@
+# Valum Benchmarking Test
+
+[Valum](http://valum-framework.org/) is a Web micro-framework written in Vala
+and leveraged by the whole GLib ecosystem.
+
+## JSON Encoding Test
+
+Uses [JSON-GLib](https://wiki.gnome.org/Projects/JsonGlib) for building and
+serializing the payload.
+
+## Test URLs
+
+### JSON Encoding Test
+
+http://localhost:3003/json
+
+### Plaintext Test
+
+http://localhost:3003/plaintext
+

+ 34 - 0
frameworks/Vala/valum/app.vala

@@ -0,0 +1,34 @@
+using GLib;
+using Valum;
+using Valum.ContentNegotiation;
+using VSGI;
+
+int main (string[] args)
+{
+	var app = new Router ();
+
+	app.use ((req, res, next) => {
+		res.headers.replace ("Server", "VSGI/0.3");
+		return next ();
+	});
+
+	app.get ("/plaintext", accept ("text/plain", (req, res) => {
+		return res.expand ("Hello, World!".data);
+	}));
+
+	app.get ("/json", accept ("application/json", (req, res, next, stack) => {
+		var builder = new Json.Builder ();
+
+		builder.begin_object ();
+		builder.set_member_name ("message");
+		builder.add_string_value ("Hello, World!");
+		builder.end_object ();
+
+		var gen = new Json.Generator ();
+		gen.root = builder.get_root ();
+
+		return res.expand (gen.to_data (null).data);
+	}));
+
+	return Server.@new ("http", handler: app).run (args);
+}

+ 22 - 0
frameworks/Vala/valum/benchmark_config.json

@@ -0,0 +1,22 @@
+{
+  "framework": "valum",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 3003,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "Valum",
+      "language": "Vala",
+      "orm": "Raw",
+      "platform": "GLib",
+      "webserver": "Soup",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Valum"
+    }
+  }]
+}

+ 12 - 0
frameworks/Vala/valum/meson.build

@@ -0,0 +1,12 @@
+project('Valum TechEmpower Benchmark', 'c', 'vala')
+
+glib_dep = dependency('glib-2.0')
+gobject_dep = dependency('gobject-2.0')
+gio_dep = dependency('glib-2.0')
+soup_dep = dependency('libsoup-2.4')
+vsgi_dep = dependency('vsgi-0.3')
+valum_dep = dependency('valum-0.3')
+json_glib_dep = dependency('json-glib-1.0')
+
+executable('app', 'app.vala',
+           dependencies: [glib_dep, gobject_dep, gio_dep, soup_dep, vsgi_dep, valum_dep, json_glib_dep])

+ 11 - 0
frameworks/Vala/valum/setup.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+fw_depends meson vala valum
+
+sudo apt-get install -y libjson-glib-dev
+
+rm -rf build
+meson --buildtype=release build
+ninja -C build
+
+build/app --forks=$(nproc --ignore 1) &

+ 21 - 0
toolset/setup/linux/frameworks/valum.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+
+VALUM_VERSION="0.3.12"
+
+fw_depends meson ninja vala
+
+fw_installed valum && return 0
+
+sudo apt-get install -y libglib2.0-dev libsoup2.4-dev
+
+fw_get -O https://github.com/valum-framework/valum/archive/v${VALUM_VERSION}.tar.gz
+fw_untar v${VALUM_VERSION}.tar.gz
+(
+	cd valum-${VALUM_VERSION}
+	rm -rf build
+	meson --prefix=${IROOT}/vala --buildtype=release --libdir=lib build # install along Vala for convenience
+	ninja -C build
+	ninja -C build install
+)
+
+touch ${IROOT}/valum.installed

+ 24 - 0
toolset/setup/linux/languages/vala.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+VALA_API_VERSION="0.36"
+VALA_VERSION="0.36.3"
+
+fw_installed vala && return 0
+
+sudo apt-get install -y flex libglib2.0-dev
+
+fw_get -O https://download.gnome.org/sources/vala/${VALA_API_VERSION}/vala-${VALA_VERSION}.tar.xz
+fw_untar vala-${VALA_VERSION}.tar.xz
+(
+	cd vala-${VALA_VERSION}
+	./configure --prefix=$IROOT/vala
+	make
+	make install
+	ln -s $IROOT/vala/share/vala-${VALA_API_VERSION}/vapi $IROOT/vala/share/vala/vapi
+)
+
+echo -e "export LD_LIBRARY_PATH=${IROOT}/vala/lib:\$LD_LIBRARY_PATH" > $IROOT/vala.installed
+echo -e "export PKG_CONFIG_PATH=${IROOT}/vala/lib/pkgconfig:\$PKG_CONFIG_PATH" >> $IROOT/vala.installed
+echo -e "export PATH=${IROOT}/vala/bin:\$PATH" >> $IROOT/vala.installed
+
+source $IROOT/vala.installed

+ 11 - 0
toolset/setup/linux/systools/meson.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+MESON_VERSION="0.40.1"
+
+fw_depends python3
+
+fw_installed meson && return 0
+
+pip3 install meson==$MESON_VERSION
+
+touch $IROOT/meson.installed

+ 13 - 0
toolset/setup/linux/systools/ninja.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+NINJA_VERSION="1.7.2"
+
+fw_installed ninja && return 0
+
+fw_get -O https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-linux.zip
+mkdir ${IROOT}/ninja
+unzip ninja-linux.zip -d ${IROOT}/ninja/bin
+
+echo -e "export PATH=${IROOT}/ninja/bin:\$PATH" > $IROOT/ninja.installed
+
+source ${IROOT}/ninja.installed