Browse Source

Merge branch 'master' of https://github.com/TechEmpower/FrameworkBenchmarks

Joshua Maddux 10 years ago
parent
commit
ac2de65bc7
59 changed files with 409 additions and 296 deletions
  1. 3 0
      .gitignore
  2. 5 3
      .travis.yml
  3. 0 3
      frameworks/C/onion/bash_profile.sh
  4. 3 1
      frameworks/C/onion/setup.sh
  5. 1 1
      frameworks/Java/gemini/Docroot/WEB-INF/resin.xml
  6. 1 1
      frameworks/Java/gemini/start.sh
  7. 1 0
      frameworks/Nim/jester/.gitignore
  8. 0 0
      frameworks/Nim/jester/README.md
  9. 2 2
      frameworks/Nim/jester/benchmark_config
  10. 0 0
      frameworks/Nim/jester/config/nginx.conf
  11. 1 1
      frameworks/Nim/jester/hello.nim
  12. 18 0
      frameworks/Nim/jester/install.sh
  13. 1 0
      frameworks/Nim/jester/jester
  14. 0 0
      frameworks/Nim/jester/public/.gitkeep
  15. 13 0
      frameworks/Nim/jester/setup.sh
  16. 6 0
      frameworks/Nim/nawak/.gitignore
  17. 0 0
      frameworks/Nim/nawak/app.nim
  18. 4 4
      frameworks/Nim/nawak/benchmark_config
  19. 0 0
      frameworks/Nim/nawak/conf/Makefile
  20. 0 0
      frameworks/Nim/nawak/conf/mongrel2.conf
  21. 0 0
      frameworks/Nim/nawak/fortunes_tmpl.nim
  22. 18 0
      frameworks/Nim/nawak/install.sh
  23. 0 0
      frameworks/Nim/nawak/model.nim
  24. 1 1
      frameworks/Nim/nawak/model_postgre.nim
  25. 1 1
      frameworks/Nim/nawak/model_redis.nim
  26. 24 0
      frameworks/Nim/nawak/setup.sh
  27. 24 0
      frameworks/Nim/nawak/setup_redis.sh
  28. 0 2
      frameworks/Nimrod/jester/.gitignore
  29. 0 3
      frameworks/Nimrod/jester/bash_profile.sh
  30. 0 3
      frameworks/Nimrod/jester/install.sh
  31. 0 11
      frameworks/Nimrod/jester/setup.sh
  32. 0 3
      frameworks/Nimrod/nawak/bash_profile.sh
  33. 0 3
      frameworks/Nimrod/nawak/install.sh
  34. 0 48
      frameworks/Nimrod/nawak/setup.py
  35. 0 20
      frameworks/Nimrod/nawak/setup.sh
  36. 0 49
      frameworks/Nimrod/nawak/setup_redis.py
  37. 21 0
      frameworks/Ruby/ngx_mruby/README.md
  38. 0 0
      frameworks/Ruby/ngx_mruby/__init__.py
  39. 26 0
      frameworks/Ruby/ngx_mruby/benchmark_config
  40. 8 0
      frameworks/Ruby/ngx_mruby/db.rb
  41. 20 0
      frameworks/Ruby/ngx_mruby/install.sh
  42. 52 0
      frameworks/Ruby/ngx_mruby/nginx.conf
  43. 27 0
      frameworks/Ruby/ngx_mruby/queries.rb
  44. 6 0
      frameworks/Ruby/ngx_mruby/setup.sh
  45. 4 0
      frameworks/Ruby/ngx_mruby/source_code
  46. 31 0
      frameworks/Ruby/ngx_mruby/updates.rb
  47. 0 58
      frameworks/Scala/play2-scala/setup_common.py
  48. 0 6
      frameworks/Scala/play2-scala/setup_scala.py
  49. 16 0
      frameworks/Scala/play2-scala/setup_scala.sh
  50. 0 6
      frameworks/Scala/play2-scala/setup_scala_anorm.py
  51. 16 0
      frameworks/Scala/play2-scala/setup_scala_anorm.sh
  52. 0 6
      frameworks/Scala/play2-scala/setup_scala_slick.py
  53. 16 0
      frameworks/Scala/play2-scala/setup_scala_slick.sh
  54. 0 9
      toolset/setup/linux/frameworks/jester.sh
  55. 0 16
      toolset/setup/linux/frameworks/nawak.sh
  56. 28 0
      toolset/setup/linux/languages/nim.sh
  57. 0 31
      toolset/setup/linux/languages/nimrod.sh
  58. 1 0
      toolset/setup/linux/prerequisites.sh
  59. 10 4
      toolset/setup/linux/webservers/mongrel2.sh

+ 3 - 0
.gitignore

@@ -72,3 +72,6 @@ beego/pkg/*
 
 # urweb
 frameworks/Ur/urweb/*.exe
+
+# nim
+nimcache

+ 5 - 3
.travis.yml

@@ -17,6 +17,7 @@ env:
     #  
     - "TESTDIR=C/lwan"
     - "TESTDIR=C/duda"
+    - "TESTDIR=C/haywire"
     - "TESTDIR=C/onion"
     - "TESTDIR=CSharp/aspnet"
     # - "TESTDIR=CSharp/aspnet-stripped"
@@ -82,8 +83,8 @@ env:
     - "TESTDIR=JavaScript/ringojs-convenient"
     - "TESTDIR=Lua/lapis"
     - "TESTDIR=Lua/openresty"
-    - "TESTDIR=Nimrod/jester"
-    - "TESTDIR=Nimrod/nawak"
+    - "TESTDIR=Nim/jester"
+    - "TESTDIR=Nim/nawak"
     - "TESTDIR=Perl/dancer"
     - "TESTDIR=Perl/kelp"
     - "TESTDIR=Perl/mojolicious"
@@ -124,6 +125,7 @@ env:
     - "TESTDIR=Python/wsgi"
     - "TESTDIR=Racket/racket-ws"
     - "TESTDIR=Ruby/grape"
+    - "TESTDIR=Ruby/ngx_mruby"
     - "TESTDIR=Ruby/padrino"
     - "TESTDIR=Ruby/rack"
     - "TESTDIR=Ruby/rails"
@@ -163,4 +165,4 @@ install:
 script: 
   # Pick one test in this directory and verify
   - time ./toolset/run-ci.py verify "$TESTDIR"
-  
+  

+ 0 - 3
frameworks/C/onion/bash_profile.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-export ONION_LOG=noinfo

+ 3 - 1
frameworks/C/onion/setup.sh

@@ -1,6 +1,8 @@
 #!/bin/bash
 
-rm -f *.o
+export ONION_LOG=noinfo
+
+make clean
 ln -s $IROOT/onion onion
 rm -f onion/build/CMakeCache.txt
 make

+ 1 - 1
frameworks/Java/gemini/Docroot/WEB-INF/resin.xml

@@ -14,7 +14,7 @@
     </server>
 
     <host>
-      <web-app id="/" root-directory="/home/tfb/FrameworkBenchmarks/gemini/Docroot" />
+      <web-app id="/" root-directory="/home/tfb/FrameworkBenchmarks/frameworks/Java/gemini/Docroot" />
     </host>
 
   </cluster>

+ 1 - 1
frameworks/Java/gemini/start.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
 sed -i 's/db.ConnectString = .*:3306/db.ConnectString = '"$DBHOST"':3306/g' Docroot/WEB-INF/GeminiHello.conf
-sed -i 's|root-directory=".*/FrameworkBenchmarks/gemini|root-directory="'"$TROOT"'|g' Docroot/WEB-INF/resin.xml
+sed -i 's|root-directory=".*/FrameworkBenchmarks/frameworks/Java/gemini|root-directory="'"$TROOT"'|g' Docroot/WEB-INF/resin.xml
 mkdir -p Docroot/WEB-INF/classes
 ant compile
 $RESIN_HOME/bin/resinctl -conf $TROOT/Docroot/WEB-INF/resin.xml start

+ 1 - 0
frameworks/Nim/jester/.gitignore

@@ -0,0 +1 @@
+/hello

+ 0 - 0
frameworks/Nimrod/jester/README.md → frameworks/Nim/jester/README.md


+ 2 - 2
frameworks/Nimrod/jester/benchmark_config → frameworks/Nim/jester/benchmark_config

@@ -9,9 +9,9 @@
       "classification": "Micro",
       "database": "MySQL",
       "framework": "jester",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "nginx",
       "os": "Linux",
       "database_os": "Linux",

+ 0 - 0
frameworks/Nimrod/jester/config/nginx.conf → frameworks/Nim/jester/config/nginx.conf


+ 1 - 1
frameworks/Nimrod/jester/hello.nim → frameworks/Nim/jester/hello.nim

@@ -1,7 +1,7 @@
 import jester, strtabs, json, asyncdispatch, os, strutils
 
 let port = Port(paramStr(1).parseInt)
-let settings = newSettings(port=port, http=true)
+let settings = newSettings(port=port)
 
 routes:
   get "/json":

+ 18 - 0
frameworks/Nim/jester/install.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+fw_depends nim nginx
+
+export PATH="$IROOT/nim/bin:$PATH"
+
+if ! nimble path jester > /dev/null 2>&1; then
+  pushd $IROOT
+  if [ ! -d jester ]; then
+    git clone https://github.com/dom96/jester.git
+  fi
+  cd jester
+  git fetch origin
+  git checkout da9e3a73ecac51494430dce2a8387e5f0e32f968
+  nimble update
+  nimble install
+  popd
+fi

+ 1 - 0
frameworks/Nim/jester/jester

@@ -0,0 +1 @@
+Subproject commit da9e3a73ecac51494430dce2a8387e5f0e32f968

+ 0 - 0
frameworks/Nimrod/jester/public/.gitkeep → frameworks/Nim/jester/public/.gitkeep


+ 13 - 0
frameworks/Nim/jester/setup.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/nginx/sbin:$PATH"
+
+nim c -d:release hello.nim
+nginx -c $TROOT/config/nginx.conf
+
+current=9000
+end=9008
+while [ $current -lt $end ]; do
+  ./hello $current &
+  let current=current+1
+done

+ 6 - 0
frameworks/Nim/nawak/.gitignore

@@ -0,0 +1,6 @@
+/nawak_postgres
+/nawak_redis
+/conf/logs
+/conf/run
+/conf/tmp
+/conf/config.sqlite

+ 0 - 0
frameworks/Nimrod/nawak/app.nim → frameworks/Nim/nawak/app.nim


+ 4 - 4
frameworks/Nimrod/nawak/benchmark_config → frameworks/Nim/nawak/benchmark_config

@@ -14,9 +14,9 @@
       "classification": "Micro",
       "database": "Postgres",
       "framework": "nawak",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "mongrel2",
       "os": "Linux",
       "database_os": "Linux",
@@ -35,9 +35,9 @@
       "classification": "Micro",
       "database": "Redis",
       "framework": "nawak",
-      "language": "Nimrod",
+      "language": "Nim",
       "orm": "Raw",
-      "platform": "Nimrod",
+      "platform": "Nim",
       "webserver": "mongrel2",
       "os": "Linux",
       "database_os": "Linux",

+ 0 - 0
frameworks/Nimrod/nawak/conf/Makefile → frameworks/Nim/nawak/conf/Makefile


+ 0 - 0
frameworks/Nimrod/nawak/conf/mongrel2.conf → frameworks/Nim/nawak/conf/mongrel2.conf


+ 0 - 0
frameworks/Nimrod/nawak/fortunes_tmpl.nim → frameworks/Nim/nawak/fortunes_tmpl.nim


+ 18 - 0
frameworks/Nim/nawak/install.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+fw_depends nim zeromq mongrel2
+
+export PATH="$IROOT/nim/bin:$PATH"
+
+if ! nimble path nawak > /dev/null 2>&1; then
+  pushd $IROOT
+  if [ ! -d nawak ]; then
+    git clone https://github.com/idlewan/nawak.git
+  fi
+  cd nawak
+  git fetch
+  git checkout b34b0b5077541ae9671957452a70e2578894d3a8
+  nimble update
+  nimble install
+  popd
+fi

+ 0 - 0
frameworks/Nimrod/nawak/model.nim → frameworks/Nim/nawak/model.nim


+ 1 - 1
frameworks/Nimrod/nawak/model_postgre.nim → frameworks/Nim/nawak/model_postgre.nim

@@ -12,7 +12,7 @@ var qupdates_prepared {.threadvar.}: TSqlPrepared
 
 proc init_db*() {.procvar.} =
     db = open("", "benchmarkdbuser", "benchmarkdbpass",
-              "host=localhost port=5432 dbname=hello_world")
+              "host=127.0.0.1 port=5432 dbname=hello_world")
     # prepare queries
     qworld_prepared = db.prepare("world", qworld, 1)
     qfortunes_prepared = db.prepare("fortunes", qfortunes, 0)

+ 1 - 1
frameworks/Nimrod/nawak/model_redis.nim → frameworks/Nim/nawak/model_redis.nim

@@ -4,7 +4,7 @@ import model
 var db {.threadvar.}: TRedis
 
 proc init_db*() {.procvar.} =
-    db = open(host="localhost")
+    db = open(host="foobar")
 
 proc getWorld*(id: int): TWorld =
     let s = redis.get(db, "world:" & $id)

+ 24 - 0
frameworks/Nim/nawak/setup.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/mongrel2/bin:$PATH"
+
+sed -i 's|host=.* port=5432|host='"${DBHOST}"' port=5432|g' model_postgre.nim
+
+echo "** Compiling app"
+nim c --threads:on -d:release -d:postgre_model -l:-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -o:nawak_postgre app.nim
+
+echo "** Starting mongrel2"
+cd conf
+mkdir -p run logs tmp
+m2sh load -config mongrel2.conf
+m2sh start -name test &
+
+cd ..
+nb_workers=256
+if [ "$TRAVIS" == "1" ]; then
+  nb_workers=32
+fi
+
+echo "** Starting app"
+
+./nawak_postgre $nb_workers &

+ 24 - 0
frameworks/Nim/nawak/setup_redis.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+export PATH="$IROOT/nim/bin:$IROOT/mongrel2/bin:$PATH"
+
+sed -i 's|host=.*)|host="'$DBHOST'")|g' model_redis.nim
+
+echo "** Compiling app"
+nim c --threads:on -d:release -d:redis_model -l:-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -o:nawak_redis app.nim
+
+echo "** Starting mongrel2"
+cd conf
+mkdir -p run logs tmp
+m2sh load -config mongrel2.conf
+m2sh start -name test &
+
+cd ..
+nb_workers=256
+if [ "$TRAVIS" == "1" ]; then
+  nb_workers=32
+fi
+
+echo "** Starting app"
+
+./nawak_redis $nb_workers &

+ 0 - 2
frameworks/Nimrod/jester/.gitignore

@@ -1,2 +0,0 @@
-nimcache
-hello

+ 0 - 3
frameworks/Nimrod/jester/bash_profile.sh

@@ -1,3 +0,0 @@
-export JESTER_PATH=${IROOT}/jester
-export NIMROD_HOME=${IROOT}/nimrod
-export NGINX_HOME=${IROOT}/nginx

+ 0 - 3
frameworks/Nimrod/jester/install.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-fw_depends nimrod nginx jester

+ 0 - 11
frameworks/Nimrod/jester/setup.sh

@@ -1,11 +0,0 @@
-#!/bin/bash
-
-${NIMROD_HOME}/bin/nim c -d:release --path:$JESTER_PATH hello.nim
-${NGINX_HOME}/sbin/nginx -c $TROOT/config/nginx.conf
-
-current=9000
-end=9008
-while [ $current -lt $end ]; do
-  ./hello $current &
-  let current=current+1
-done

+ 0 - 3
frameworks/Nimrod/nawak/bash_profile.sh

@@ -1,3 +0,0 @@
-export NAWAK_PATH=${IROOT}/nawak
-export NIMROD_HOME=${IROOT}/nimrod
-export ZEROMQ_HOME=${IROOT}/zeromq-4.0.3

+ 0 - 3
frameworks/Nimrod/nawak/install.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-
-fw_depends nimrod zeromq mongrel2 nawak

+ 0 - 48
frameworks/Nimrod/nawak/setup.py

@@ -1,48 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-from os.path import expanduser
-
-home = expanduser("~")
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("nawak/model_postgre.nim", "host=.* port=5432",
-                          "host=" + args.database_host + " port=5432")
-  # compile the app
-  subprocess.check_call(
-      "nim c --threads:on -d:release -d:postgre_model --path:$NAWAK_PATH -o:nawak_postgre app.nim",
-      shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  # launch mongrel2
-  subprocess.check_call("mkdir -p run logs tmp", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh load -config mongrel2.conf", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  
-  # launch workers
-  if os.environ.get("TRAVIS"):
-    nb_workers = 32
-  else:
-    nb_workers = 256
-  subprocess.Popen("./nawak_postgre " + str(nb_workers),
-                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  return 0
-
-def stop(logfile, errfile):
-  ret = 0
-
-  try:
-    subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except Exception:
-    ret = 1
-
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'nawak_postgre' in line:
-      try:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-      except OSError:
-        ret = 1
-
-  return ret

+ 0 - 20
frameworks/Nimrod/nawak/setup.sh

@@ -1,20 +0,0 @@
-#!/bin/bash
-
-sed -i 's|host=.* port=5432|host='"${DBHOST}"' port=5432|g' model_postgre.nim
-
-export PATH=$NIMROD_HOME/bin:$NAWAK_HOME/bin:$ZEROMQ_HOME/include:$NAWAK_PATH:$PATH
-
-nim c --threads:on -d:release -d:postgre_model --path:$NAWAK_PATH -o:nawak_postgre app.nim
-
-cd conf
-mkdir -p run logs tmp
-m2sh load -config mongrel2.conf
-m2sh start -name test
-
-cd ..
-nb_workers=256
-if [ "$TRAVIS" == "1" ]; then
-  nb_workers=32
-if
-
-./nawak_postgre &

+ 0 - 49
frameworks/Nimrod/nawak/setup_redis.py

@@ -1,49 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-from os.path import expanduser
-
-home = expanduser("~")
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("nawak/model_redis.nim",
-                          'open\(host=.*\)',
-                          'open(host="' + args.database_host + '")')
-  # compile the app
-  subprocess.check_call(
-      "nim c --threads:on -d:release -d:redis_model --path:$NAWAK_PATH -o:nawak_redis app.nim",
-      shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  # launch mongrel2
-  subprocess.check_call("mkdir -p run logs tmp", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh load -config mongrel2.conf", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  
-  # launch workers
-  if os.environ.get("TRAVIS"):
-    nb_workers = 32
-  else:
-    nb_workers = 256
-  subprocess.Popen("./nawak_redis " + str(nb_workers),
-                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
-  return 0
-
-def stop(logfile, errfile):
-  ret = 0
-
-  try:
-    subprocess.check_call("sudo m2sh stop -every", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
-  except Exception:
-    ret = 1
-
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'nawak_redis' in line:
-      try:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-      except OSError:
-        ret = 1
-
-  return ret

+ 21 - 0
frameworks/Ruby/ngx_mruby/README.md

@@ -0,0 +1,21 @@
+# [nginx + mruby](https://github.com/matsumoto-r/ngx_mruby) Benchmark Test
+
+The nginx app is distributes across a few files. most of it is in [nginx.conf](nginx.conf)
+The nginx conf is inside [nginx.conf](nginx.conf)
+Requires a nginx compiled with ngx_mruby module. It has been called nginx_mruby for lack of a better name
+
+
+## Test URLs
+### JSON Encoding
+
+http://localhost:8080/json
+
+### Single Row Random Query
+
+http://localhost:8080/db
+
+### Variable Row Query Test
+
+http://localhost:8080/db?queries=2
+
+Based upon the [openresty](../../Lua/openresty/) implementation.

+ 0 - 0
frameworks/Ruby/ngx_mruby/__init__.py


+ 26 - 0
frameworks/Ruby/ngx_mruby/benchmark_config

@@ -0,0 +1,26 @@
+{
+  "framework": "ngx_mruby",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "ngx_mruby",
+      "language": "Ruby",
+      "orm": "Raw",
+      "platform": "ngx_mruby",
+      "webserver": "nginx",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "ngx_mruby",
+      "notes": "",
+      "versus": "ngx_mruby"
+    }
+  }]
+}

+ 8 - 0
frameworks/Ruby/ngx_mruby/db.rb

@@ -0,0 +1,8 @@
+# https://github.com/mattn/mruby-mysql/blob/master/example/example.rb
+db = Userdata.new("my_#{Process.pid}").db
+
+ret = nil
+db.execute("select * from World where id = ?", rand(10000)) do |row, fields|
+  ret = Hash[fields.zip(row)]
+end
+Nginx.rputs JSON::stringify(ret)

+ 20 - 0
frameworks/Ruby/ngx_mruby/install.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+PREFIX=${IROOT}/nginx_mruby
+
+RETCODE=$(fw_exists ${IROOT}/nginx_mruby.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+fw_depends rvm
+rvm install ruby-2.0.0-p0
+rvm use ruby-2.0.0-p0
+git clone git://github.com/matsumoto-r/ngx_mruby.git
+cd ngx_mruby
+git submodule init
+git submodule update
+[ -d mruby/mrbgems/mruby-mysql ] || git clone git://github.com/mattn/mruby-mysql.git mruby/mrbgems/mruby-mysql
+
+NGINX_CONFIG_OPT_ENV="--prefix=${PREFIX} --with-http_stub_status_module" sh build.sh
+make install
+
+touch ${IROOT}/nginx_mruby.installed

+ 52 - 0
frameworks/Ruby/ngx_mruby/nginx.conf

@@ -0,0 +1,52 @@
+pid        /tmp/nginx.pid;
+error_log stderr error;
+worker_processes auto;
+
+events {
+    worker_connections  16384;
+    multi_accept on;
+}
+
+http {
+    resolver 127.0.0.1;
+    access_log off;
+    mruby_init_worker_code 'Userdata.new("my_#{Process.pid}").db = MySQL::Database.new("DBHOSTNAME", "benchmarkdbuser", "benchmarkdbpass", "hello_world")';
+    mruby_exit_worker_code 'db = Userdata.new("my_#{Process.pid}").db ; db.close if db';
+    server {
+        listen       8080;
+        server_name  localhost;
+
+        location / {
+            root   html;
+            index  index.html index.htm;
+        }
+
+        location /plaintext {
+            default_type "text/plain";
+            mruby_content_handler_code 'Nginx.rputs "Hello, world!"';
+        }
+
+        location /json {
+            default_type "application/json";
+            mruby_content_handler_code 'Nginx.rputs JSON::stringify("message" => "Hello, World!")';
+        }
+
+        location ~ /db {
+            default_type "application/json";
+            #note: next line has cwd
+            mruby_content_handler 'CWD/db.rb' cache;
+        }
+
+        location ~ /queries {
+            default_type "application/json";
+            #note: next line has cwd
+            mruby_content_handler 'CWD/queries.rb' cache;
+        }
+
+#        location ~ /fortunes {
+#            default_type "application/html";
+#            #note: next line has cwd
+#            mruby_content_handler 'CWD/fortunes.rb' cache;
+#        }
+    }
+}

+ 27 - 0
frameworks/Ruby/ngx_mruby/queries.rb

@@ -0,0 +1,27 @@
+class World
+  def db
+    @db ||= Userdata.new("my_#{Process.pid}").db
+  end
+
+  def find(id)
+    ret = nil
+    db.execute("select * from World where id = ?", id) do |row, fields|
+      ret = Hash[fields.zip(row)]
+    end
+    ret
+  end
+
+  def save(world)
+    db.execute("update World set randomNumber = ? where id = ?", world["randomNumber"], world["randomNumber"])
+  end
+end
+
+r = Nginx::Request.new
+
+num_queries = r.var.arg_queries.to_i
+num_queries = 1 if num_queries < 1
+num_queries = 500 if num_queries > 500
+
+world = World.new
+ret = num_queries.times.map { world.find(rand(10000)) }
+Nginx.rputs JSON::stringify(ret)

+ 6 - 0
frameworks/Ruby/ngx_mruby/setup.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+sed -i 's|CWD|'"${TROOT}"'|g' nginx.conf
+sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' nginx.conf
+
+${IROOT}/nginx_mruby/sbin/nginx -c $TROOT/nginx.conf &

+ 4 - 0
frameworks/Ruby/ngx_mruby/source_code

@@ -0,0 +1,4 @@
+./ngx_mruby/db.rb
+./ngx_mruby/fortune.rb
+./ngx_mruby/queries.rb
+./ngx_mruby/updates.rb

+ 31 - 0
frameworks/Ruby/ngx_mruby/updates.rb

@@ -0,0 +1,31 @@
+r = Nginx::Request.new
+
+num_queries = r.var.arg_queries.to_i
+num_queries = 1 if num_queries < 0
+num_queries = 500 if num_queries > 500
+
+class Worlds
+  def db
+    @db ||= Userdata.new("my_#{Process.pid}").db
+  end
+
+  def find(id)
+    db.execute("select * from World where id = ?", id) do |row, fields|
+      return Hash[fields.zip(row)]
+    end
+  end
+
+  def save(world)
+    #TODO: consider execute_batch
+    db.execute("update World set randomNumber = ? where id = ?", world["randomNumber"], world["randomNumber"])
+  end
+end
+
+ret = num_queries.times.map { World.find(rand(10000)) }
+
+ret.each do |world|
+  world["randomNumber"] = rand(10000) + 1
+  World.save(world)
+end
+
+Nginx.rputs JSON::stringify(ret)

+ 0 - 58
frameworks/Scala/play2-scala/setup_common.py

@@ -1,58 +0,0 @@
-# This file and frameworks/Java/play2-java/setup_common.py are
-# duplicates and should be kept in sync.
-
-import os, setup_util, signal, subprocess
-
-# Create start and stop functions for the Play project with the given dir
-# and install them in the given module's globals.
-def make_setup_for_dir(module_globals, subtest_name):
-
-  def start(args, logfile, errfile):
-    kill_running_process(logfile)
-
-    subtest_dir = get_subtest_dir()
-    install_dir = os.environ['IROOT']
-
-    is_windows = os.name == "nt"
-    cmd_suffix = '.bat' if is_windows else ''
-    sbt_cmd = os.path.join(install_dir, 'sbt', 'bin', 'sbt'+cmd_suffix)
-    app_cmd = os.path.join(subtest_dir, 'target','universal','stage','bin',subtest_name+cmd_suffix)
-
-    setup_util.replace_text(
-      os.path.join(subtest_dir,'conf','application.conf'),
-      "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
-    logfile.write('Staging app: '+sbt_cmd+' stage\n')
-    subprocess.call(
-      [sbt_cmd, 'stage'],
-      stdin=subprocess.PIPE, cwd=subtest_dir, stderr=errfile, stdout=logfile)
-    logfile.write('Starting app: '+app_cmd+'\n')
-    subprocess.Popen(
-      [app_cmd],
-      shell=True, stdin=subprocess.PIPE, cwd=subtest_dir, stderr=errfile, stdout=logfile)
-    return 0
-
-  def stop(logfile, errfile):
-    kill_running_process(logfile)  
-    return 0
-
-  # Install the start and stop functions in the calling module
-  module_globals['start'] = start
-  module_globals['stop'] = stop
-
-  def get_subtest_dir():
-    test_dir = os.environ['TROOT']
-    return os.path.join(test_dir, subtest_name)
-
-  # Kill the running process and delete the RUNNING_PID file (if any).
-  def kill_running_process(logfile):
-    subtest_dir = get_subtest_dir()
-    pidfile = os.path.join(subtest_dir,"target","universal","stage","RUNNING_PID")
-    if not os.path.exists(pidfile):
-      logfile.write('No PID file: {}\n'.format(pidfile))
-      return
-    logfile.write('Reading and deleting PID file: {}\n'.format(pidfile))
-    with open(pidfile) as f:
-      pid = int(f.read())
-    os.remove(pidfile)
-    logfile.write('Sending SIGTERM to process: {}\n'.format(pid))
-    os.kill(pid, signal.SIGTERM)

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-scala/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala/target/universal/stage/bin/play2-scala &

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala_anorm.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala-anorm')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala_anorm.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala-anorm
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application has an already existing process id, clear it.
+if [ -f ${TROOT}/play2-scala-anorm/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala-anorm/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala-anorm/target/universal/stage/bin/play2-scala-anorm &

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala_slick.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala-slick')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala_slick.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala-slick
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-scala-slick/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala-slick/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala-slick/target/universal/stage/bin/play2-scala-slick &

+ 0 - 9
toolset/setup/linux/frameworks/jester.sh

@@ -1,9 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists jester)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-git clone git://github.com/dom96/jester.git jester
-cd jester
-# most recent commit in branch new-async as of 2014-10-31
-git checkout 3e77ce753293b523004dfdaebd2fb195217f30f0

+ 0 - 16
toolset/setup/linux/frameworks/nawak.sh

@@ -1,16 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists ${IROOT}/nawak.installed)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-fw_depends nimrod
-
-git clone git://github.com/idlewan/nawak.git nawak
-cd nawak
-# version 0.3.0 (2014-11-02)
-git checkout b34b0b5077541ae9671957452a70e2578894d3a8
-
-${IROOT}/nimrod/bin/nimble update
-${IROOT}/nimrod/bin/nimble install
-
-touch ${IROOT}/nawak.installed

+ 28 - 0
toolset/setup/linux/languages/nim.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+RETCODE=$(fw_exists $IROOT/nim.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+test -d nim || git clone git://github.com/Araq/Nim.git nim
+cd nim
+# post version 0.10.2 - most recent as of 2014-12-
+git checkout v0.10.2
+
+test -d csources || git clone git://github.com/nim-lang/csources.git
+cd csources
+sh build.sh
+cd ..
+
+bin/nim c koch
+
+# bootstrapping nim's compiler
+./koch boot -d:release
+
+# nim's package manager
+test -d nimble || git clone git://github.com/nim-lang/nimble.git
+cd nimble
+git checkout v0.6
+../bin/nim c src/nimble
+mv src/nimble ../bin/
+
+touch $IROOT/nim.installed

+ 0 - 31
toolset/setup/linux/languages/nimrod.sh

@@ -1,31 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists $IROOT/nim.installed)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-test -d nimrod || git clone git://github.com/Araq/Nimrod.git nimrod
-cd nimrod 
-# post version 0.9.6 - most recent as of 2014-10-31
-git checkout bbb16713c1bbc266cb8d69f262cc302641e361c4
-
-test -d csources || git clone git://github.com/nimrod-code/csources.git
-cd csources
-# post version 0.9.6 - most recent as of 2014-10-31
-git checkout b0bcf88e26730b23d22e2663adf1babb05bd5a71
-sh build.sh
-cd ..
-
-bin/nimrod c koch
-
-# bootstrapping nim's compiler
-./koch boot -d:release
-
-# nim's package manager
-test -d nimble || git clone git://github.com/nimrod-code/nimble.git
-cd nimble
-# post version 0.4.0 - most recent as of 2014-10-31
-git checkout ecd78e0e0300a8178db320d83014d3eb47a89b4c
-../bin/nim c src/nimble
-mv src/nimble ../bin/
-
-touch $IROOT/nim.installed

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

@@ -41,6 +41,7 @@ sudo apt-get -yq install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::
   libjson0-dev libmcrypt-dev libicu-dev gettext \
   libpq-dev mlton \
   libjemalloc-dev                   `# Needed by lwan at least` \
+  libhiredis-dev                    `# Redis client - Needed by ngx_mruby at least` \
   cloc dstat                        `# Collect resource usage statistics`
 
 # Install gcc-4.8

+ 10 - 4
toolset/setup/linux/webservers/mongrel2.sh

@@ -13,7 +13,6 @@ sudo ldconfig -v
 
 fw_get https://github.com/zedshaw/mongrel2/tarball/v1.8.1 -O mongrel2.tar.gz
 fw_untar mongrel2.tar.gz
-mv mongrel2 mongrel2-install
 
 # mongrel2 untars into this folder 
 mv zedshaw-mongrel2-aa2ecf8 mongrel2-install
@@ -23,7 +22,14 @@ fw_get https://raw.github.com/zedshaw/mongrel2/9b565eeea003783c47502c2d350b99c96
 mv -f zmq_compat.h mongrel2-install/src/
 
 cd mongrel2-install
-PREFIX=${IROOT}/mongrel2 make clean all
-PREFIX=${IROOT}/mongrel2 make install
 
-touch ${IROOT}/mongrel2.installed
+# Do this in a subshell to avoid leaking env variables
+(
+  export PREFIX=${IROOT}/mongrel2
+  export OPTFLAGS="-I$IROOT/zeromq-4.0.3/include"
+  export OPTLIBS="-Wl,-rpath,$IROOT/zeromq-4.0.3/lib -L$IROOT/zeromq-4.0.3/lib"
+  make clean all
+  make install
+)
+
+touch ${IROOT}/mongrel2.installed