Browse Source

Merge remote-tracking branch 'upstream/master'

Zane Kansil 10 years ago
parent
commit
ed92769302
100 changed files with 1172 additions and 811 deletions
  1. 0 1
      .travis.yml
  2. 15 2
      config/postgresql.conf
  3. 3 1
      deployment/vagrant-common/core.rb
  4. 6 6
      deployment/vagrant-production/Vagrantfile
  5. 3 13
      frameworks/C++/ULib/benchmark_config
  6. 4 4
      frameworks/C++/ULib/install.sh
  7. 9 0
      frameworks/C++/ULib/setup.sh
  8. 2 1
      frameworks/C++/ULib/setup_mysql.sh
  9. 2 1
      frameworks/C++/ULib/setup_postgres.sh
  10. 2 1
      frameworks/C++/ULib/setup_sqlite.sh
  11. 32 22
      frameworks/C++/ULib/src/db.usp
  12. 25 15
      frameworks/C++/ULib/src/fortune.usp
  13. 6 0
      frameworks/C++/ULib/src/json.usp
  14. 32 21
      frameworks/C++/ULib/src/query.usp
  15. 43 33
      frameworks/C++/ULib/src/update.usp
  16. 35 67
      frameworks/C++/wt/benchmark.cpp
  17. 74 4
      frameworks/C/lwan/README.md
  18. 1 1
      frameworks/C/lwan/install.sh
  19. 18 14
      frameworks/Java/activeweb/benchmark_config
  20. 48 11
      frameworks/Java/activeweb/pom.xml
  21. 14 14
      frameworks/Java/activeweb/source_code
  22. 2 4
      frameworks/Java/activeweb/src/main/java/app/config/AppBootstrap.java
  23. 2 2
      frameworks/Java/activeweb/src/main/java/app/config/AppControllerConfig.java
  24. 0 30
      frameworks/Java/activeweb/src/main/java/app/config/FreeMarkerConfig.java
  25. 1 4
      frameworks/Java/activeweb/src/main/java/app/config/RouteConfig.java
  26. 0 39
      frameworks/Java/activeweb/src/main/java/app/controllers/DatabaseController.java
  27. 40 0
      frameworks/Java/activeweb/src/main/java/app/controllers/DbController.java
  28. 16 19
      frameworks/Java/activeweb/src/main/java/app/controllers/FortunesController.java
  29. 24 33
      frameworks/Java/activeweb/src/main/java/app/controllers/JsonController.java
  30. 15 22
      frameworks/Java/activeweb/src/main/java/app/controllers/PlaintextController.java
  31. 26 32
      frameworks/Java/activeweb/src/main/java/app/controllers/QueriesController.java
  32. 18 21
      frameworks/Java/activeweb/src/main/java/app/controllers/UpdatesController.java
  33. 1 1
      frameworks/Java/activeweb/src/main/java/app/models/Fortune.java
  34. 38 0
      frameworks/Java/activeweb/src/main/java/app/models/Message.java
  35. 19 17
      frameworks/Java/activeweb/src/main/java/app/models/World.java
  36. 1 0
      frameworks/Java/activeweb/src/main/resources/activeweb.properties
  37. 0 20
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.ftl
  38. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.html
  39. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.html
  40. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/json/index.html
  41. 10 5
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.html
  42. 0 3
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/footer.ftl
  43. 0 4
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/header.ftl
  44. 0 7
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.ftl
  45. 1 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.html
  46. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.html
  47. 0 0
      frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.html
  48. 0 46
      frameworks/Java/activeweb/src/test/java/app/controllers/DatabaseControllerSpec.java
  49. 66 0
      frameworks/Java/activeweb/src/test/java/app/controllers/DbControllerSpec.java
  50. 48 0
      frameworks/Java/activeweb/src/test/java/app/controllers/FortunesControllerSpec.java
  51. 33 26
      frameworks/Java/activeweb/src/test/java/app/controllers/JsonControllerSpec.java
  52. 42 0
      frameworks/Java/activeweb/src/test/java/app/controllers/PlaintextControllerSpec.java
  53. 3 3
      frameworks/Java/curacao/build.sbt
  54. 2 2
      frameworks/Java/curacao/src/main/java/benchmark/Benchmarks.java
  55. 3 3
      frameworks/Java/gemini/benchmark_config
  56. 3 3
      frameworks/Java/netty/pom.xml
  57. 8 1
      frameworks/Java/netty/src/main/java/hello/HelloWebServer.java
  58. 8 1
      frameworks/Java/play2-java/setup_java.sh
  59. 8 1
      frameworks/Java/play2-java/setup_java_ebean_bonecp.sh
  60. 8 1
      frameworks/Java/play2-java/setup_java_ebean_hikaricp.sh
  61. 8 1
      frameworks/Java/play2-java/setup_java_jpa_bonecp.sh
  62. 8 1
      frameworks/Java/play2-java/setup_java_jpa_hikaricp.sh
  63. 1 1
      frameworks/Java/servlet/pom.xml
  64. 2 1
      frameworks/Java/servlet3-cass/bash_profile.sh
  65. 1 1
      frameworks/Java/servlet3-cass/install.sh
  66. 5 5
      frameworks/Java/servlet3-cass/pom.xml
  67. 0 2
      frameworks/Java/servlet3-cass/source_code
  68. 2 2
      frameworks/Java/spring/README.md
  69. 1 1
      frameworks/Java/spring/pom.xml
  70. 26 0
      frameworks/Java/spring/src/main/java/com/techempower/spring/SampleApplication.java
  71. 1 1
      frameworks/Java/undertow-edge/pom.xml
  72. 1 1
      frameworks/Java/undertow/pom.xml
  73. 2 0
      frameworks/Java/wildfly-ee7/benchmark_config
  74. 2 2
      frameworks/Java/wildfly-ee7/pom.xml
  75. 1 1
      frameworks/Java/wildfly-ee7/server-resources/datasources/mysql-ds.xml
  76. 1 1
      frameworks/Java/wildfly-ee7/setup.sh
  77. 8 17
      frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/jpa/PersistenceResources.java
  78. 6 8
      frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/rest/CatchAllExceptionMapper.java
  79. 34 36
      frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/tests/Updates.java
  80. 28 27
      frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/Helpers.java
  81. 0 15
      frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/LoggerProducer.java
  82. 1 1
      frameworks/PHP/hhvm/setup_hhvm.sh
  83. 15 36
      frameworks/Perl/mojolicious/app.pl
  84. 2 2
      frameworks/Perl/mojolicious/benchmark_config
  85. 2 2
      frameworks/Perl/mojolicious/cpanfile
  86. 120 25
      frameworks/Perl/mojolicious/cpanfile.snapshot
  87. 1 0
      frameworks/Perl/mojolicious/setup.sh
  88. 3 2
      frameworks/Python/API-Hour/hello/etc/hello/main/main.yaml
  89. 16 22
      frameworks/Python/API-Hour/hello/hello/services/world.py
  90. 1 1
      frameworks/Python/bottle/setup_nginxuwsgi.sh
  91. 1 1
      frameworks/Python/flask/setup_nginxuwsgi.sh
  92. 1 1
      frameworks/Python/uwsgi/setup_nginx.sh
  93. 1 1
      frameworks/Python/wsgi/setup_nginxuwsgi.sh
  94. 11 4
      frameworks/Ruby/grape/install.sh
  95. 6 1
      frameworks/Ruby/grape/run_jruby_puma.sh
  96. 6 1
      frameworks/Ruby/grape/run_mri_puma.sh
  97. 6 1
      frameworks/Ruby/grape/run_rbx_puma.sh
  98. 6 1
      frameworks/Ruby/grape/run_thin.sh
  99. 6 1
      frameworks/Ruby/grape/run_torqbox.sh
  100. 7 2
      frameworks/Ruby/grape/run_trinidad.sh

+ 0 - 1
.travis.yml

@@ -136,7 +136,6 @@ env:
     - "TESTDIR=Scala/lift-stateless"
     - "TESTDIR=Scala/plain"
     - "TESTDIR=Scala/play-activate-mysql"
-    - "TESTDIR=Scala/play-scala-mongodb"
     - "TESTDIR=Scala/play2-scala"
     - "TESTDIR=Scala/scalatra"
     - "TESTDIR=Scala/scruffy"

+ 15 - 2
config/postgresql.conf

@@ -105,8 +105,21 @@ ssl = false                             # (change requires restart)
 #------------------------------------------------------------------------------
 
 # - Memory -
-
-shared_buffers = 32MB			# min 128kB
+# values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench
+# details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html
+# http://www.postgresql.org/docs/9.4/static/runtime-config-query.html
+shared_buffers = 2GB                    # min 128kB
+work_mem = 64MB                                # min 64kB
+maintenance_work_mem = 512MB            # min 1MB
+checkpoint_segments = 64
+checkpoint_completion_target = 0.9
+effective_cache_size = 8GB
+
+# when executed on the SSD (otherwise 4)
+random_page_cost = 2
+
+#shared_buffers = 32MB			# min 128kB
 					# (change requires restart)
 #temp_buffers = 8MB			# min 800kB
 #max_prepared_transactions = 0		# zero disables the feature

+ 3 - 1
deployment/vagrant-common/core.rb

@@ -77,7 +77,9 @@ def provider_aws(config, role, ip_address='172.16.0.16')
   end
 end
 
-def provider_virtualbox(config, role)
+def provider_virtualbox(config, role, ip_address='172.16.0.16')
+  config.vm.network "private_network", ip: ip_address
+  
   config.vm.provider :virtualbox do |vb, override|
     override.vm.hostname = "TFB-#{role}"
 

+ 6 - 6
deployment/vagrant-production/Vagrantfile

@@ -8,9 +8,9 @@ check_provider_needs(provider)
 
 Vagrant.configure("2") do |config|
 
-  server_ip = ENV.fetch('TFB_AWS_LOAD_IP', '172.16.0.16')
-  client_ip = ENV.fetch('TFB_AWS_DB_IP', '172.16.0.17')
-  databa_ip = ENV.fetch('TFB_AWS_APP_IP', '172.16.0.18')
+  server_ip = ENV.fetch('TFB_AWS_APP_IP', '172.16.0.16')
+  client_ip = ENV.fetch('TFB_AWS_LOAD_IP', '172.16.0.17')
+  databa_ip = ENV.fetch('TFB_AWS_DB_IP', '172.16.0.18')
   
   # Put the keys inside each box
   Dir['keys/*'].each do |fname|
@@ -28,20 +28,20 @@ Vagrant.configure("2") do |config|
   config.vm.define "client" do |client|
     provision_bootstrap(client, "client")
     provider_aws(client, "loadgen", client_ip)
-    provider_virtualbox(client, "client")
+    provider_virtualbox(client, "client", client_ip)
   end
 
   config.vm.define "db" do |db|
     provision_bootstrap(db, "database")
     provider_aws(db, "database", databa_ip)
-    provider_virtualbox(db, "database")
+    provider_virtualbox(db, "database", databa_ip)
   end
 
   # Define the app server as the primary VM
   config.vm.define "app", primary: true do |app|
     provision_bootstrap(app, "server")
     provider_aws(app, "appserver", server_ip)
-    provider_virtualbox(app, "server")
+    provider_virtualbox(app, "server", server_ip)
   end
 
 end

+ 3 - 13
frameworks/C++/ULib/benchmark_config

@@ -2,17 +2,13 @@
   "framework": "ULib",
   "tests": [{
     "default": {
-      "setup_file": "setup_mysql",
+      "setup_file": "setup",
       "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/query?queries=",
-      "fortune_url": "/fortune",
-      "update_url": "/update?queries=",
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
-      "database": "MySQL",
+      "database": "None",
       "framework": "ULib",
       "language": "C++",
       "orm": "Micro",
@@ -20,18 +16,16 @@
       "webserver": "userver_tcp",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "ULib-mysql",
+      "display_name": "ULib",
       "notes": "",
       "versus": ""
     },
     "mysql": {
       "setup_file": "setup_mysql",
-      "json_url": "/json",
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
-      "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
@@ -49,11 +43,9 @@
     },
     "sqlite": {
       "setup_file": "setup_sqlite",
-      "json_url": "/json",
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",
-      "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
@@ -71,12 +63,10 @@
     },
     "postgres": {
       "setup_file": "setup_postgres",
-      "json_url": "/json",
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
-      "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",

+ 4 - 4
frameworks/C++/ULib/install.sh

@@ -41,12 +41,12 @@ if [ ! -f "benchmark.cfg" ]; then
   cat <<EOF >benchmark.cfg
 userver {
  PORT 8080
- PREFORK_CHILD 8
- LISTEN_BACKLOG 8192
- MAX_KEEP_ALIVE 8192
+ PREFORK_CHILD 4
+ MAX_KEEP_ALIVE 1023
+ LISTEN_BACKLOG 16384
+ CLIENT_FOR_PARALLELIZATION 256
  ORM_DRIVER "mysql pgsql sqlite"
  DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
-#PID_FILE ${ULIB_ROOT}/userver_tcp.pid
 }
 EOF
 fi

+ 9 - 0
frameworks/C++/ULib/setup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+export UMEMPOOL="176,100,0,37,1160,155,-17,-22,40"
+
+# 1. Change ULib Server configuration
+sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
+
+# 2. Start ULib Server (userver_tcp)
+${IROOT}/ULib/bin/userver_tcp -c ${IROOT}/ULib/benchmark.cfg &

+ 2 - 1
frameworks/C++/ULib/setup_mysql.sh

@@ -1,9 +1,10 @@
 #!/bin/bash
 
-export UMEMPOOL="545,0,0,37,8465,0,-17,-22,34"
 export ORM_DRIVER="mysql"
 export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
 
+export UMEMPOOL="176,100,0,37,1160,155,-17,-22,40"
+
 # 1. Change ULib Server configuration
 sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
 

+ 2 - 1
frameworks/C++/ULib/setup_postgres.sh

@@ -1,9 +1,10 @@
 #!/bin/bash
 
-export UMEMPOOL="545,0,0,37,8465,0,-17,-22,34"
 export ORM_DRIVER="pgsql"
 export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world client_encoding=UTF8"
 
+export UMEMPOOL="176,100,0,37,1160,155,-17,-22,40"
+
 # 1. Change ULib Server configuration
 sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
 

+ 2 - 1
frameworks/C++/ULib/setup_sqlite.sh

@@ -1,9 +1,10 @@
 #!/bin/bash
 
-export UMEMPOOL="545,0,0,37,8465,0,-17,-22,34"
 export ORM_DRIVER="sqlite"
 export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=${ULIB_ROOT}/db/%.*s"
 
+export UMEMPOOL="176,100,0,37,1160,155,-17,-22,40"
+
 # 1. Change ULib Server configuration
 sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
 

+ 32 - 22
frameworks/C++/ULib/src/db.usp

@@ -1,48 +1,58 @@
+<!--#
+Test type 2: Single database query
+TechEmpower Web Framework Benchmarks
+-->
 <!--#declaration
 #include "world.h"
 
-#ifndef AS_cpoll_cppsp_DO
-static UValue* pvalue;
-#endif
 static World*         pworld_db;
 static UOrmSession*   psql_db;
 static UOrmStatement* pstmt_db;
 
-static void usp_init_db()
-{
-   U_TRACE(5, "::usp_init_db()")
-
-   pworld_db = U_NEW(World);
-
 #ifndef AS_cpoll_cppsp_DO
-   pvalue = U_NEW(UValue(OBJECT_VALUE));
+static UValue* pvalue;
 #endif
-}
 
 static void usp_fork_db()
 {
    U_TRACE(5, "::usp_fork_db()")
 
-   psql_db  = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
-   pstmt_db = U_NEW(UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
+   psql_db = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
+
+   if (psql_db->isReady())
+      {
+      pstmt_db = U_NEW(UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
+
+      if (pstmt_db == 0) U_ERROR("usp_fork_db(): we cound't connect to db");
+
+      pworld_db = U_NEW(World);
 
-   if (pstmt_db == 0) U_ERROR("usp_fork_db(): we cound't connect to db");
+      pstmt_db->use( pworld_db->id);
+      pstmt_db->into(pworld_db->randomNumber);
 
-   pstmt_db->use( pworld_db->id);
-   pstmt_db->into(pworld_db->randomNumber);
+#  ifndef AS_cpoll_cppsp_DO
+      pvalue = U_NEW(UValue(OBJECT_VALUE));
+#  endif
+      }
 }
 
+#ifdef DEBUG
 static void usp_end_db()
 {
    U_TRACE(5, "::usp_end_db()")
 
-   delete pstmt_db;
-   delete psql_db;
-   delete pworld_db;
-#ifndef AS_cpoll_cppsp_DO
-   delete pvalue;
-#endif
+   if (pstmt_db)
+      {
+      delete  pstmt_db;
+      delete   psql_db;
+      delete pworld_db;
+
+#  ifndef AS_cpoll_cppsp_DO
+      delete pvalue;
+#  endif
+      }
 }
+#endif
 -->
 <!--#header
 Content-Type: application/json; charset=UTF-8

+ 25 - 15
frameworks/C++/ULib/src/fortune.usp

@@ -1,43 +1,53 @@
+<!--#
+Test type 4: Fortunes
+TechEmpower Web Framework Benchmarks
+-->
 <!--#declaration
 #include "fortune.h"
 
-static UOrmSession*       psql_fortune;
-static UOrmStatement*     pstmt_fortune;
 static Fortune*           pfortune;
 static UString*           pmessage;
+static UOrmSession*       psql_fortune;
+static UOrmStatement*     pstmt_fortune;
 static UVector<Fortune*>* pvfortune;
 
-static void usp_init_fortune()
-{
-   U_TRACE(5, "::usp_init_fortune()")
-
-   pfortune  = U_NEW(Fortune);
-   pvfortune = U_NEW(UVector<Fortune*>);
-   pmessage  = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
-}
-
 static void usp_fork_fortune()
 {
    U_TRACE(5, "::usp_fork_fortune()")
 
-   psql_fortune  = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
-   pstmt_fortune = U_NEW(UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
+   psql_fortune = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
+
+   if (psql_fortune->isReady())
+      {
+      pstmt_fortune = U_NEW(UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
+
+      if (pstmt_fortune == 0) U_ERROR("usp_fork_fortune(): we cound't connect to db");
+
+      pfortune = U_NEW(Fortune);
 
-   if (pstmt_fortune == 0) U_ERROR("usp_fork_fortune(): we cound't connect to db");
+      pstmt_fortune->into(*pfortune);
 
-   pstmt_fortune->into(*pfortune);
+      pmessage  = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
+      pvfortune = U_NEW(UVector<Fortune*>);
+      }
 }
 
+#ifdef DEBUG
 static void usp_end_fortune()
 {
    U_TRACE(5, "::usp_end_fortune()")
 
+   if (pstmt_fortune)
+   {
    delete pstmt_fortune;
+
    delete psql_fortune;
    delete pvfortune;
    delete pfortune;
    delete pmessage;
+   }
 }
+#endif
 -->
 <!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
 Fortune* elem;

+ 6 - 0
frameworks/C++/ULib/src/json.usp

@@ -1,3 +1,7 @@
+<!--#
+Test type 1: JSON serialization
+TechEmpower Web Framework Benchmarks
+-->
 <!--#declaration
 #ifdef AS_cpoll_cppsp_DO
 #undef AS_cpoll_cppsp_DO
@@ -19,6 +23,7 @@ static void usp_init_json()
 #endif
 }
 
+#ifdef DEBUG
 static void usp_end_json()
 {
    U_TRACE(5, "::usp_end_json()")
@@ -28,6 +33,7 @@ static void usp_end_json()
    delete pvalue;
 #endif
 }
+#endif
 -->
 <!--#header
 Content-Type: application/json; charset=UTF-8

+ 32 - 21
frameworks/C++/ULib/src/query.usp

@@ -1,51 +1,62 @@
+<!--#
+Test type 3: Multiple database queries
+TechEmpower Web Framework Benchmarks
+-->
 <!--#declaration
 #include "world.h"
 
-#ifndef AS_cpoll_cppsp_DO
-static UValue* pvalue;
-#endif
+static World*           pworld_query;
 static UOrmSession*     psql_query;
 static UOrmStatement*   pstmt_query;
-static World*           pworld_query;
 static UVector<World*>* pvworld_query;
 
-static void usp_init_query()
-{
-   U_TRACE(5, "::usp_init_query()")
-
-   pworld_query  = U_NEW(World);
-   pvworld_query = U_NEW(UVector<World*>(500));
-
 #ifndef AS_cpoll_cppsp_DO
-   pvalue = U_NEW(UValue(ARRAY_VALUE));
+static UValue* pvalue;
 #endif
-}
 
 static void usp_fork_query()
 {
    U_TRACE(5, "::usp_fork_query()")
 
-   psql_query  = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
-   pstmt_query = U_NEW(UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
+   psql_query = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
+
+   if (psql_query->isReady())
+      {
+      pstmt_query = U_NEW(UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
+
+      if (pstmt_query == 0) U_ERROR("usp_fork_query(): we cound't connect to db");
+
+      pworld_query = U_NEW(World);
+
+      pstmt_query->use( pworld_query->id);
+      pstmt_query->into(pworld_query->randomNumber);
 
-   if (pstmt_query == 0) U_ERROR("usp_fork_query(): we cound't connect to db");
+      pvworld_query = U_NEW(UVector<World*>(500));
 
-   pstmt_query->use( pworld_query->id);
-   pstmt_query->into(pworld_query->randomNumber);
+#  ifndef AS_cpoll_cppsp_DO
+      pvalue = U_NEW(UValue(ARRAY_VALUE));
+#  endif
+      }
 }
 
+#ifdef DEBUG
 static void usp_end_query()
 {
    U_TRACE(5, "::usp_end_query()")
 
-   delete pstmt_query;
-   delete psql_query;
+   if (pstmt_query)
+   {
+   delete   pstmt_query;
+   delete    psql_query;
    delete pvworld_query;
-   delete pworld_query;
+   delete  pworld_query;
+
 #ifndef AS_cpoll_cppsp_DO
    delete pvalue;
 #endif
+   }
 }
+#endif
 -->
 <!--#args
 queries;

+ 43 - 33
frameworks/C++/ULib/src/update.usp

@@ -1,26 +1,19 @@
+<!--#
+Test type 5: Database updates
+TechEmpower Web Framework Benchmarks
+-->
 <!--#declaration
 #include "world.h"
 
-#ifndef AS_cpoll_cppsp_DO
-static UValue* pvalue;
-#endif
+static World*           pworld_update;
 static UOrmSession*     psql_update;
 static UOrmStatement*   pstmt1;
 static UOrmStatement*   pstmt2;
-static World*           pworld_update;
 static UVector<World*>* pvworld_update;
 
-static void usp_init_update()
-{
-   U_TRACE(5, "::usp_init_update()")
-
-   pworld_update  = U_NEW(World);
-   pvworld_update = U_NEW(UVector<World*>(500));
-
 #ifndef AS_cpoll_cppsp_DO
-   pvalue = U_NEW(UValue(ARRAY_VALUE));
+static UValue* pvalue;
 #endif
-}
 
 static void usp_fork_update()
 {
@@ -28,33 +21,52 @@ static void usp_fork_update()
 
    psql_update = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
 
-   pstmt1 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
-   pstmt2 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
-
-   if (pstmt1 == 0 ||
-       pstmt2 == 0)
+   if (psql_update->isReady())
       {
-      U_ERROR("usp_fork_update(): we cound't connect to db");
-      }
+      pstmt1 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
+      pstmt2 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
 
-   pstmt1->use( pworld_update->id);
-   pstmt1->into(pworld_update->randomNumber);
-   pstmt2->use( pworld_update->randomNumber, pworld_update->id);
+      if (pstmt1 == 0 ||
+          pstmt2 == 0)
+         {
+         U_ERROR("usp_fork_update(): we cound't connect to db");
+         }
+
+      pworld_update = U_NEW(World);
+
+      pstmt1->use( pworld_update->id);
+      pstmt1->into(pworld_update->randomNumber);
+      pstmt2->use( pworld_update->randomNumber, pworld_update->id);
+
+      pvworld_update = U_NEW(UVector<World*>(500));
+
+#  ifndef AS_cpoll_cppsp_DO
+      pvalue = U_NEW(UValue(ARRAY_VALUE));
+#  endif
+      }
 }
 
+#ifdef DEBUG
 static void usp_end_update()
 {
    U_TRACE(5, "::usp_end_update()")
 
-   delete pstmt1;
-   delete pstmt2;
-   delete psql_update;
-   delete pvworld_update;
-   delete pworld_update;
-#ifndef AS_cpoll_cppsp_DO
-   delete pvalue;
-#endif
+   if (pstmt1 &&
+       pstmt2)
+      {
+      delete pstmt1;
+      delete pstmt2;
+
+      delete    psql_update;
+      delete pvworld_update;
+      delete  pworld_update;
+
+#  ifndef AS_cpoll_cppsp_DO
+      delete pvalue;
+#  endif
+      }
 }
+#endif
 -->
 <!--#args
 queries;
@@ -78,8 +90,6 @@ while (true)
 
    pstmt1->execute();
 
-   U_INTERNAL_DUMP("pworld_update->randomNumber = %u", pworld_update->randomNumber)
-
    pworld_update->randomNumber = u_get_num_random(10000);
 
    pstmt2->execute();

+ 35 - 67
frameworks/C++/wt/benchmark.cpp

@@ -91,57 +91,38 @@ public:
     }
 };
 
-std::mutex mtx;
-
-struct DbStruct {
-#ifndef BENCHMARK_USE_POSTGRES
-  Wt::Dbo::backend::MySQL connection;
+class MyConnection : public
+#ifdef BENCHMARK_USE_POSTGRES
+  Wt::Dbo::backend::Postgres
 #else
-  Wt::Dbo::backend::Postgres connection;
+  Wt::Dbo::backend::MySQL
 #endif
-  Wt::Dbo::Session session;
-  Wt::Dbo::Transaction *transaction;
-
-  boost::taus88 rng;
-  boost::random::uniform_int_distribution<int> distribution;
-
-#ifndef BENCHMARK_USE_POSTGRES
-  DbStruct() : connection("hello_world", "benchmarkdbuser", "benchmarkdbpass", "INSERT_DB_HOST_HERE", 3306),
+{
+public:
+#ifdef BENCHMARK_USE_POSTGRES
+  MyConnection(const std::string &db) :
+  Wt::Dbo::backend::Postgres(db) {}
 #else
-  DbStruct() : connection("host=INSERT_DB_HOST_HERE port=5432 user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"),
+  MyConnection(const std::string &db, const std::string &dbuser, const std::string &dbpasswd, const std::string &dbhost, unsigned int dbport) :
+  Wt::Dbo::backend::MySQL(db, dbuser, dbpasswd, dbhost, dbport) {}
 #endif
-      rng(clock()),
-      distribution(1, 10000) {
-    session.setConnection(connection);
-    session.mapClass<World>("world");
-    session.mapClass<Fortune>("fortune");
-    transaction = new Wt::Dbo::Transaction(session);
-  }
-
-  ~DbStruct() {
-    delete transaction;
-  }
 
-  int rand() {
-    return distribution(rng);
-  }
+  virtual void startTransaction() { }
+  virtual void commitTransaction() { }
+  virtual void rollbackTransaction() { }
 };
 
-struct DbStructNoTransaction {
-#ifndef BENCHMARK_USE_POSTGRES
-  Wt::Dbo::backend::MySQL connection;
-#else
-  Wt::Dbo::backend::Postgres connection;
-#endif
+struct DbStruct {
+  MyConnection connection;
   Wt::Dbo::Session session;
 
   boost::taus88 rng;
   boost::random::uniform_int_distribution<int> distribution;
 
 #ifndef BENCHMARK_USE_POSTGRES
-  DbStructNoTransaction() : connection("hello_world", "benchmarkdbuser", "benchmarkdbpass", "INSERT_DB_HOST_HERE", 3306),
+  DbStruct() : connection("hello_world", "benchmarkdbuser", "benchmarkdbpass", "INSERT_DB_HOST_HERE", 3306),
 #else
-  DbStructNoTransaction() : connection("host=INSERT_DB_HOST_HERE port=5432 user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"),
+  DbStruct() : connection("host=INSERT_DB_HOST_HERE port=5432 user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"),
 #endif
       rng(clock()),
       distribution(1, 10000) {
@@ -155,9 +136,11 @@ struct DbStructNoTransaction {
   }
 };
 
-class DbResource : public Wt::WResource {
-private:
+namespace {
   boost::thread_specific_ptr<DbStruct> dbStruct_;
+}
+
+class DbResource : public Wt::WResource {
 public:
   virtual void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) {
     response.setMimeType("application/json");
@@ -165,13 +148,11 @@ public:
 
     DbStruct* db = dbStruct_.get();
     if (!db) {
-      std::lock_guard<std::mutex> lock(mtx);
-      if (!db) {
-        db = new DbStruct();
-        dbStruct_.reset(db);
-      }
+      db = new DbStruct();
+      dbStruct_.reset(db);
     }
 
+    Wt::Dbo::Transaction transaction(db->session);
     Wt::Dbo::ptr<World> entry = db->session.load<World>(db->rand());
     
     Wt::Dbo::JsonSerializer writer(response.out());
@@ -180,8 +161,6 @@ public:
 };
 
 class QueriesResource : public Wt::WResource {
-private:
-  boost::thread_specific_ptr<DbStruct> dbStruct_;
 public:
   virtual void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) {
     int n;
@@ -200,13 +179,11 @@ public:
 
     DbStruct* db = dbStruct_.get();
     if (!db) {
-      std::lock_guard<std::mutex> lock(mtx);
-      if (!db) {
-        db = new DbStruct();
-        dbStruct_.reset(db);
-      }
+      db = new DbStruct();
+      dbStruct_.reset(db);
     }
 
+    Wt::Dbo::Transaction transaction(db->session);
     std::vector<Wt::Dbo::ptr<World> > results;
     results.reserve(n);
     for (int i = 0; i < n; ++i) {
@@ -250,7 +227,7 @@ public:
 
   virtual void resolveString(const std::string& varName, const std::vector<Wt::WString>& vars, std::ostream& result) {
     if (varName == "id")
-      format(result, Wt::WString::fromUTF8(boost::lexical_cast<std::string>(it_->id())), Wt::XHTMLUnsafeText);
+      result << it_->id();
     else if (varName == "message")
       format(result, Wt::WString::fromUTF8((*it_)->message));
     else
@@ -259,8 +236,6 @@ public:
 };
 
 class FortuneResource : public Wt::WResource {
-private:
-  boost::thread_specific_ptr<DbStruct> dbStruct_;
 public:
   virtual void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) {
     response.setMimeType("text/html; charset=utf-8");
@@ -268,13 +243,11 @@ public:
 
     DbStruct* db = dbStruct_.get();
     if (!db) {
-      std::lock_guard<std::mutex> lock(mtx);
-      if (!db) {
-        db = new DbStruct();
-        dbStruct_.reset(db);
-      }
+      db = new DbStruct();
+      dbStruct_.reset(db);
     }
 
+    Wt::Dbo::Transaction transaction(db->session);
     Fortunes fortunes = db->session.find<Fortune>();
     VFortunes vFortunes;
     for (Fortunes::const_iterator i = fortunes.begin(); i != fortunes.end(); ++i)
@@ -293,8 +266,6 @@ public:
 };
 
 class UpdateResource : public Wt::WResource {
-private:
-  boost::thread_specific_ptr<DbStructNoTransaction> dbStruct_;
 public:
   virtual void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) {
     int n;
@@ -311,13 +282,10 @@ public:
     response.setMimeType("application/json");
     response.addHeader("Server", "Wt");
 
-    DbStructNoTransaction* db = dbStruct_.get();
+    DbStruct* db = dbStruct_.get();
     if (!db) {
-      std::lock_guard<std::mutex> lock(mtx);
-      if (!db) {
-        db = new DbStructNoTransaction();
-        dbStruct_.reset(db);
-      }
+      db = new DbStruct();
+      dbStruct_.reset(db);
     }
 
     std::vector<Wt::Dbo::ptr<World> > results;

+ 74 - 4
frameworks/C/lwan/README.md

@@ -1,11 +1,82 @@
 # Lwan
 
-This is the configuration files to benchmark the [Lwan](http://lwan.ws)
+This is the configuration files to benchmark the [Lwan](http://lwan.ws/?src=twfb)
 web server/framework.
 
+## FAQ
+
+### Where's the source code for the benchmark?
+
+Source code for the benchmark itself is currently living in [in Lwan's
+repository](https://github.com/lpereira/lwan/tree/master/techempower) for
+practical reasons, but will move to [this repository right after Round 10 is
+complete](https://github.com/TechEmpower/FrameworkBenchmarks/issues/1372).
+
+In any case, the script to install the framework in the test machines [pulls
+a specific snapshot of the Lwan source
+code](https://github.com/lpereira/lwan/tree/49607addb31879e2aa2b701317773674662315aa),
+including the benchmark code; and, due to the nature of Git, it's not
+possible to alter that code without changing which commit hash to checkout
+in this repository.
+
+### The JSON test RPS value seems ridiculous; is Lwan cheating?
+
+Come on. There's no optimization without cheating. There's a somewhat
+[detailed blog post about
+this](http://tia.mat.br/blog/html/2014/10/06/life_of_a_http_request.html?src=twfb).
+However, that level of cheating is considered by Lwan's author to be fair
+game, since it's not related to the benchmark code itself.
+
+In fact, the serialization library has been picked solely because it was
+available in the [CCAN](http://ccodearchive.net/).  It's written by [Joseph
+A.  Adams](http://ccodearchive.net/info/json.html), and has been slightly
+tweaked to fix some compiler warnings and a few other minor changes.  No
+major optimization or trickery has been made there: it's essentially the
+same code.  Props to him for a clean code that performs well.
+
+It's all open source anyway, feel free to go ahead and inspect the code.
+
+### The database results aren't that good. Why?
+
+The database tests are included for completeness sake. The database
+abstraction layer (which works with SQLite and MySQL) was written
+specifically for this benchmark, and is completely synchronous: while
+one query is being performed, all other clients wait.
+
+So the uninspiring results are expected. Database connectivity is
+important and will eventually be revisited.
+
+### I've seen the preliminary results and Lwan didn't fare well in the plaintext benchmark. Is there a reason why?
+
+These benchmarks are performed using pipelined requests. For practical
+reasons (almost no client supports them, at least by default), this was not
+implemented in Lwan: the server was dropping the request buffer and waiting
+for the next request to come in, while `wrk` was waiting for responses to
+come out, eventually timeouting and sending more pipelined requests, only to
+repeat, until the test actually ended.
+
+Pipelining has been implemented in a hurry to get included in Round 10.
+
+### The results are pretty good, can I use this in my next web app?
+
+Writing web apps in C? Only if you're Crazy. (The uppercase C is not a typo.)
+
+Seriously, Lwan is just a toy.  It's an experiment.  Most things you'll need
+from real frameworks won't be available.  You'll have a hard time trying to do
+the simplest things.  There are far more important things to look for while
+picking a framework, and performance, while important, is not the most
+important factor.  However, if you're feeling adventurous, know that Lwan is
+free software, and is very open to pull requests.
+
+### I have other questions, is there a FAQ somewhere else?
+
+Sure there is. [See Lwan's web page](http://lwan.ws/?src=twfb) or contact the author
+directly.
+
 ## Requirements
 
-GCC, SQLite 3.7, Linux 3.0, optionally jemalloc or tcmalloc.
+GCC, SQLite 3.7, MySQL/MariaDB client libraries, Lua 5.1/LuaJit 2.0, Linux 3.0,
+optionally jemalloc or tcmalloc.
 
 ## Tests available
 
@@ -29,7 +100,6 @@ URL: /fortunes
 
 URL: /plaintext
 
-
 ## Contact
 
-Leandro Pereira <[email protected]>
+[Leandro Pereira](http://tia.mat.br/?src=twfb) <[[email protected]](mailto:[email protected])>

+ 1 - 1
frameworks/C/lwan/install.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-REV='8ae98d2b6e146948a7ed13e76141e0f69228d690'
+REV='49607addb31879e2aa2b701317773674662315aa'
 
 INSTALLED_FILE="${IROOT}/lwan-${REV}.installed"
 RETCODE=$(fw_exists ${INSTALLED_FILE})

+ 18 - 14
frameworks/Java/activeweb/benchmark_config

@@ -4,15 +4,19 @@
     "default": {
       "setup_file": "setup",
       "json_url": "/activeweb/json",
+      "db_url": "/activeweb/db",
+      "query_url": "/activeweb/queries?queries=",
+      "fortune_url": "/activeweb/fortunes",
+      "update_url": "/activeweb/updates?queries=",
       "plaintext_url": "/activeweb/plaintext",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Platform",
-      "database": "None",
+      "classification": "Fullstack",
+      "database": "MySQL",
       "framework": "activeweb",
       "language": "Java",
-      "orm": "Raw",
-      "platform": "ActiveWeb",
+      "orm": "Micro",
+      "platform": "Servlet",
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
@@ -20,24 +24,24 @@
       "notes": "",
       "versus": "servlet"
     },
-    "raw": {
+    "jackson": {
       "setup_file": "setup",
-      "db_url": "/activeweb/db",
-      "query_url": "/activeweb/queries?queries=",
-      "fortune_url": "/activeweb/fortunes",
-      "update_url": "/activeweb/updates?queries=",
+      "json_url": "/activeweb/json/jackson",
+      "db_url": "/activeweb/db/jackson",
+      "query_url": "/activeweb/queries/jackson?queries=",
+      "update_url": "/activeweb/updates/jackson?queries=",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Platform",
+      "classification": "Fullstack",
       "database": "MySQL",
-      "framework": "ActiveWeb",
+      "framework": "activeweb",
       "language": "Java",
-      "orm": "Raw",
-      "platform": "ActiveWeb",
+      "orm": "Micro",
+      "platform": "Servlet",
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "activeweb",
+      "display_name": "ActiveWeb",
       "notes": "",
       "versus": "servlet"
     }

+ 48 - 11
frameworks/Java/activeweb/pom.xml

@@ -9,7 +9,8 @@
     <name>ActiveWeb Benchmark App</name>
 
     <properties>
-        <activeweb.version>1.9</activeweb.version>
+        <activeweb.version>1.11</activeweb.version>
+        <activejdbc.version>1.4.10</activejdbc.version>
     </properties>
 
     <build>
@@ -18,7 +19,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.14.1</version>
+                <version>2.18.1</version>
                 <configuration>
                     <reportFormat>brief</reportFormat>
                     <trimStackTrace>true</trimStackTrace>
@@ -51,12 +52,18 @@
                             <maxIdleTime>1000</maxIdleTime>
                         </connector>
                     </connectors>
+                    <!--<systemProperties>-->
+                        <!--<systemProperty>-->
+                            <!--<name>active_reload</name>-->
+                            <!--<value>true</value>-->
+                        <!--</systemProperty>-->
+                    <!--</systemProperties>-->
                 </configuration>
             </plugin>
             <plugin>
                 <groupId>org.javalite</groupId>
                 <artifactId>activejdbc-instrumentation</artifactId>
-                <version>1.4.9</version>
+                <version>${activejdbc.version}</version>
                 <executions>
                     <execution>
                         <phase>process-classes</phase>
@@ -73,7 +80,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.8.1</version>
+            <version>4.12</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -81,6 +88,11 @@
             <artifactId>activeweb</artifactId>
             <version>${activeweb.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.javalite</groupId>
+            <artifactId>activejdbc</artifactId>
+            <version>${activejdbc.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.javalite</groupId>
             <artifactId>activeweb-testing</artifactId>
@@ -98,18 +110,43 @@
             <artifactId>slf4j-simple</artifactId>
             <version>1.7.5</version>
         </dependency>
-
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-core</artifactId>
-            <version>2.3.1</version>
+            <version>2.4.4</version>
         </dependency>
-
         <dependency>
-          <groupId>com.fasterxml.jackson.core</groupId>
-          <artifactId>jackson-databind</artifactId>
-          <version>2.3.1</version>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.4.4</version>
         </dependency>
-
     </dependencies>
+
+    <repositories>
+        <repository>
+            <id>javaLite-snapshots</id>
+            <name>JavaLite Snapshots</name>
+            <url>http://repo.javalite.io/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+    <pluginRepositories>
+        <pluginRepository>
+            <id>javaLite-plugin-snapshots</id>
+            <name>JavaLite Plugin Snapshots</name>
+            <url>http://repo.javalite.io/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </pluginRepository>
+    </pluginRepositories>
+
 </project>

+ 14 - 14
frameworks/Java/activeweb/source_code

@@ -1,14 +1,14 @@
-./src/main/java/app/config/AppControllerConfig.java
-./src/main/java/app/config/RouteConfig.java
-./src/main/java/app/config/FreeMarkerConfig.java
-./src/main/java/app/config/DbConfig.java
-./src/main/java/app/config/AppBootstrap.java
-./src/main/java/app/models/World.java
-./src/main/java/app/models/Fortune.java
-./src/main/java/app/controllers/PlaintextController.java
-./src/main/java/app/controllers/JsonController.java
-./src/main/java/app/controllers/DatabaseController.java
-./src/main/java/app/controllers/FortunesController.java
-./src/main/java/app/controllers/QueriesController.java
-./src/main/java/app/controllers/HomeController.java
-./src/main/java/app/controllers/UpdatesController.java
+./activeweb/src/main/java/app/config/AppBootstrap.java
+./activeweb/src/main/java/app/config/AppControllerConfig.java
+./activeweb/src/main/java/app/config/DbConfig.java
+./activeweb/src/main/java/app/config/RouteConfig.java
+./activeweb/src/main/java/app/controllers/DbController.java
+./activeweb/src/main/java/app/controllers/FortunesController.java
+./activeweb/src/main/java/app/controllers/HomeController.java
+./activeweb/src/main/java/app/controllers/JsonController.java
+./activeweb/src/main/java/app/controllers/PlaintextController.java
+./activeweb/src/main/java/app/controllers/QueriesController.java
+./activeweb/src/main/java/app/controllers/UpdatesController.java
+./activeweb/src/main/java/app/models/Fortune.java
+./activeweb/src/main/java/app/models/Message.java
+./activeweb/src/main/java/app/models/World.java

+ 2 - 4
frameworks/Java/activeweb/src/main/java/app/config/AppBootstrap.java

@@ -17,15 +17,13 @@ package app.config;
 
 import org.javalite.activeweb.AppContext;
 import org.javalite.activeweb.Bootstrap;
-
-import com.google.inject.Guice;
-import org.javalite.activeweb.Configuration;
+import org.javalite.templator.TemplatorConfig;
 
 /**
  * @author Igor Polevoy
  */
 public class AppBootstrap extends Bootstrap {
     public void init(AppContext context) {
-        Configuration.setUseDefaultLayoutForErrors(true);
+        TemplatorConfig.instance().cacheTemplates(true);
     }
 }

+ 2 - 2
frameworks/Java/activeweb/src/main/java/app/config/AppControllerConfig.java

@@ -16,7 +16,7 @@ limitations under the License.
 package app.config;
 
 
-import app.controllers.DatabaseController;
+import app.controllers.DbController;
 import app.controllers.FortunesController;
 import app.controllers.QueriesController;
 import app.controllers.UpdatesController;
@@ -33,7 +33,7 @@ public class AppControllerConfig extends AbstractControllerConfig {
     public void init(AppContext context) {
 //        addGlobalFilters(new TimingFilter()); for speed - not sure how logging is configured
 
-        add(new DBConnectionFilter()).to(DatabaseController.class, QueriesController.class,
+        add(new DBConnectionFilter()).to(DbController.class, QueriesController.class,
                 FortunesController.class, UpdatesController.class);
     }
 }

+ 0 - 30
frameworks/Java/activeweb/src/main/java/app/config/FreeMarkerConfig.java

@@ -1,30 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
-
-http://www.apache.org/licenses/LICENSE-2.0 
-
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
-*/
-
-package app.config;
-
-import org.javalite.activeweb.freemarker.AbstractFreeMarkerConfig;
-
-/**
- * @author Igor Polevoy
- */
-public class FreeMarkerConfig extends org.javalite.activeweb.freemarker.AbstractFreeMarkerConfig {
-    @Override
-    public void init() {
-        //this is to override a strange FreeMarker default processing of numbers 
-        getConfiguration().setNumberFormat("0.##");
-    }
-}

+ 1 - 4
frameworks/Java/activeweb/src/main/java/app/config/RouteConfig.java

@@ -20,13 +20,10 @@ limitations under the License.
 
 package app.config;
 
-import app.controllers.DatabaseController;
 import org.javalite.activeweb.AbstractRouteConfig;
 import org.javalite.activeweb.AppContext;
 
 public class RouteConfig extends AbstractRouteConfig {
-    @Override
-    public void init(AppContext appContext) {
-        route("/db").to(DatabaseController.class);
+    @Override public void init(AppContext appContext) {
     }
 }

+ 0 - 39
frameworks/Java/activeweb/src/main/java/app/controllers/DatabaseController.java

@@ -1,39 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
-
-http://www.apache.org/licenses/LICENSE-2.0 
-
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
-*/
-
-/**
- * @author Igor Polevoy: 12/18/13 4:36 PM
- */
-
-package app.controllers;
-
-import app.models.World;
-import org.javalite.activeweb.AppController;
-
-import java.util.Date;
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-
-public class DatabaseController extends AppController {
-    public void index() {
-
-        String json = World.findById(ThreadLocalRandom.current().nextInt(10000)).toJson(false, "id", "randomNumber");
-
-        respond(json).contentType("application/json")
-                .header("Content-Length", String.valueOf(json.length()))
-                .header("Date", new Date().toString());
-    }
-}

+ 40 - 0
frameworks/Java/activeweb/src/main/java/app/controllers/DbController.java

@@ -0,0 +1,40 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package app.controllers;
+
+import app.models.World;
+import java.io.IOException;
+import org.javalite.activeweb.AppController;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * @author Igor Polevoy: 12/18/13 4:36 PM
+ * @author Eric Nielsen
+ */
+public class DbController extends AppController {
+    public void index() {
+        respond(World.findById(randomNumber()).toJson(false, "id", "randomNumber")).contentType("application/json");
+    }
+
+    public void jackson() throws IOException {
+        JsonController.WRITER.writeValue(outputStream("application/json"), World.findById(randomNumber()));
+    }
+
+    protected int randomNumber(){
+        return ThreadLocalRandom.current().nextInt(10000) + 1;
+    }
+}

+ 16 - 19
frameworks/Java/activeweb/src/main/java/app/controllers/FortunesController.java

@@ -1,23 +1,18 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 9:11 PM
- */
-
 package app.controllers;
 
 import app.models.Fortune;
@@ -25,17 +20,19 @@ import org.javalite.activeweb.AppController;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 
+/**
+ * @author Igor Polevoy: 12/18/13 9:11 PM
+ * @author Eric Nielsen
+ */
 public class FortunesController extends AppController {
-
     public void index() {
         List<Fortune> dbFortunes = Fortune.findAll();
         List<Fortune> fortunes = new ArrayList<Fortune>(dbFortunes);
-        fortunes.add((Fortune) Fortune.create("id", 0, "message", "Additional fortune added at request time."));
+        fortunes.add(Fortune.<Fortune>create("id", 0, "message", "Additional fortune added at request time."));
         Collections.sort(fortunes);
         view("fortunes", fortunes);
-        render().noLayout();
+        render("/fortunes/index").noLayout();
     }
 }

+ 24 - 33
frameworks/Java/activeweb/src/main/java/app/controllers/JsonController.java

@@ -1,49 +1,40 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 3:51 PM
- */
-
 package app.controllers;
 
+import app.models.Message;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import java.io.IOException;
 import org.javalite.activeweb.AppController;
 
-import java.io.IOException;
-import java.util.Date;
 
+/**
+ * @author Igor Polevoy: 12/18/13 3:51 PM
+ * @author Eric Nielsen
+ */
 public class JsonController extends AppController {
-    public void index() throws IOException {
-        String json = new ObjectMapper().writeValueAsString(new Message("Hello, World!"));
-        respond(json)
-                .contentType("application/json")
-                .header("Content-Length", String.valueOf(json.length()))
-                .header("Date", new Date().toString());
-    }
-
-    public static final class Message {
-        private final String message;
+    static final ObjectWriter WRITER = new ObjectMapper().writer();
 
-        private Message(String message) {
-            this.message = message;
-        }
+    public void index() {
+        view("message", new Message("Hello, World!"));
+        render("/json/index").noLayout().contentType("application/json");
+    }
 
-        public String getMessage() {
-            return message;
-        }
+    public void jackson() throws IOException {
+        WRITER.writeValue(outputStream("application/json"), new Message("Hello, World!"));
     }
 }

+ 15 - 22
frameworks/Java/activeweb/src/main/java/app/controllers/PlaintextController.java

@@ -1,35 +1,28 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/19/13 1:23 AM
- */
-
 package app.controllers;
 
 import org.javalite.activeweb.AppController;
 
-import java.util.Date;
-
+/**
+ * @author Igor Polevoy: 12/19/13 1:23 AM
+ * @author Eric Nielsen
+ */
 public class PlaintextController extends AppController {
     public void index() {
-        String message = "Hello, World!";
-        respond(message)
-                .contentType("text/plain")
-                .header("Content-Length", String.valueOf(message.length()))
-                .header("Date", new Date().toString());
+        respond("Hello, World!").contentType("text/plain");
     }
 }

+ 26 - 32
frameworks/Java/activeweb/src/main/java/app/controllers/QueriesController.java

@@ -1,40 +1,42 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 4:36 PM
- */
-
 package app.controllers;
 
 import app.models.World;
-import org.javalite.activeweb.AppController;
+import java.io.IOException;
 
 import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
 
-public class QueriesController extends AppController {
+/**
+ * @author Igor Polevoy: 12/18/13 4:36 PM
+ * @author Eric Nielsen
+ */
+public class QueriesController extends DbController {
+    @Override public void index() {
+        view("worlds", getWorlds());
+        render("/queries/index").contentType("application/json");
+    }
 
-    public void index() {
+    @Override public void jackson() throws IOException {
+        JsonController.WRITER.writeValue(outputStream("application/json"), getWorlds());
+    }
 
-        view("worlds", getWorlds());
-        render().contentType("application/json").header("Date", new Date().toString());
+    @Override protected String getLayout() {
+        return null;
     }
 
     protected List<World> getWorlds() {
@@ -46,7 +48,7 @@ public class QueriesController extends AppController {
         return worlds;
     }
 
-    public int getQueries() {
+    protected int getQueries() {
         int queries;
         try {
             queries = Integer.parseInt(param("queries"));
@@ -60,12 +62,4 @@ public class QueriesController extends AppController {
         }
         return queries;
     }
-    protected int randomNumber(){
-        return ThreadLocalRandom.current().nextInt(10000) + 1;
-    }
-
-    @Override
-    protected String getLayout() {
-        return null;
-    }
 }

+ 18 - 21
frameworks/Java/activeweb/src/main/java/app/controllers/UpdatesController.java

@@ -1,38 +1,35 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 9:51 PM
- */
-
 package app.controllers;
 
 import app.models.World;
-import org.javalite.activeweb.AppController;
 
 import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
 
+/**
+ * @author Igor Polevoy: 12/18/13 9:51 PM
+ * @author Eric Nielsen
+ */
 public class UpdatesController extends QueriesController {
-    public void index() {
-        List<World> worlds = getWorlds();
+
+    @Override protected List<World> getWorlds() {
+        List<World> worlds = super.getWorlds();
         for (World world : worlds) {
             world.set("randomNumber", randomNumber()).saveIt();
         }
-        view("worlds", worlds);
-        render("/queries/index"); //same template
+        return worlds;
     }
 }

+ 1 - 1
frameworks/Java/activeweb/src/main/java/app/models/Fortune.java

@@ -25,7 +25,7 @@ import org.javalite.activejdbc.annotations.Table;
 
 @Table("Fortune")
 public class Fortune extends Model implements Comparable<Fortune> {
-    public int compareTo(Fortune other) {
+    @Override public int compareTo(Fortune other) {
         return getString("message").compareTo(other.getString("message"));
     }
 }

+ 38 - 0
frameworks/Java/activeweb/src/main/java/app/models/Message.java

@@ -0,0 +1,38 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package app.models;
+
+/**
+ * @author Eric Nielsen
+ */
+public class Message {
+    private String message;
+
+    public Message() {
+    }
+
+    public Message(String message) {
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

+ 19 - 17
frameworks/Java/activeweb/src/main/java/app/models/World.java

@@ -1,30 +1,32 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 4:32 PM
- */
-
 package app.models;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import org.javalite.activejdbc.Model;
 import org.javalite.activejdbc.annotations.Table;
 
-
+/**
+ * @author Igor Polevoy: 12/18/13 4:32 PM
+ * @author Eric Nielsen
+ */
 @Table("World")
+@JsonIgnoreProperties({"frozen", "idName", "longId", "new", "valid"})
 public class World extends Model {
-
+    public Object getRandomNumber() {
+        return get("randomNumber");
+    }
 }

+ 1 - 0
frameworks/Java/activeweb/src/main/resources/activeweb.properties

@@ -0,0 +1 @@
+templateManager=org.javalite.activeweb.templator.TemplatorManager

+ 0 - 20
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.ftl

@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head><title>Fortunes</title></head>
-<body>
-<table>
-    <tr>
-        <th>id</th>
-        <th>message</th>
-    </tr>
-
-<#list fortunes as fortune>
-    <tr>
-        <td>${fortune.id}</td>
-        <td>${fortune.message?html}</td>
-    </tr>
-</#list>
-
-</table>
-</body>
-</html>

+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/fortunes/index.html

@@ -0,0 +1 @@
+<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><#list fortunes as fortune ><tr><td>${fortune.id}</td><td>${fortune.message esc}</td></tr></#list></table></body></html>

+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/home/index.html


+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/json/index.html

@@ -0,0 +1 @@
+{"message":"${message.message}"}

+ 10 - 5
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/default_layout.html

@@ -1,21 +1,26 @@
-<#setting url_escaping_charset='ISO-8859-1'>
-
 <html>
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
     <LINK href="${context_path}/css/main.css" rel="stylesheet" type="text/css"/>
     <script src="${context_path}/js/jquery-1.4.2.min.js" type="text/javascript"></script>
     <script src="${context_path}/js/aw.js" type="text/javascript"></script>
-    <title>ActiveWeb - <@yield to="title"/></title>
+    <title>ActiveWeb</title>
 </head>
 <body>
 
 <div class="main">
-<#include "header.ftl" >
+    <div class="header">
+        <h1><a href="${context_path}">ActiveWeb Benchmark Application</a></h1>
+    </div>
+
+
     <div class="content">
     ${page_content}
     </div>
-<#include "footer.ftl" >
+    <div class='footer'>
+        <p>2010 - 2015 Active Web.</p>
+    </div>
+
 </div>
 
 </body>

+ 0 - 3
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/footer.ftl

@@ -1,3 +0,0 @@
-<div class='footer'>
-    <p>2010 - 2013 Active Web. No Rights Reserved.</p>
-</div>

+ 0 - 4
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/layouts/header.ftl

@@ -1,4 +0,0 @@
-<div class="header">
-    <h1><a href="${context_path}">ActiveWeb Benchmark Application</a></h1>
-</div>
-

+ 0 - 7
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.ftl

@@ -1,7 +0,0 @@
-<@compress single_line=true>
-[<#list worlds as w>
-{"id":${w.id},"randomNumber":${w.randomNumber}}
-<#if w_has_next>,</#if>
-</#list>
-]
-</@compress>

+ 1 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/queries/index.html

@@ -0,0 +1 @@
+[<#list worlds as w >{"id":${w.id},"randomNumber":${w.randomNumber}}<#if w_has_next >,</#if></#list>]

+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/404.html


+ 0 - 0
frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.ftl → frameworks/Java/activeweb/src/main/webapp/WEB-INF/views/system/error.html


+ 0 - 46
frameworks/Java/activeweb/src/test/java/app/controllers/DatabaseControllerSpec.java

@@ -1,46 +0,0 @@
-/*
-Copyright 2009-2010 Igor Polevoy 
-
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
-
-http://www.apache.org/licenses/LICENSE-2.0 
-
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
-*/
-
-/**
- * @author Igor Polevoy: 12/18/13 4:42 PM
- */
-
-package app.controllers;
-
-
-import org.javalite.activeweb.DBControllerSpec;
-import org.junit.Test;
-
-import java.util.Map;
-
-public class DatabaseControllerSpec extends DBControllerSpec {
-
-    @Test
-    public void shouldRenderOneRecord(){
-
-        //execute controller
-        request().get("index");
-
-        //process result
-        Map result = JsonHelper.toMap(responseContent());
-
-        //test result
-        a(result.size()).shouldBeEqual(2);
-        a(result.get("id")).shouldNotBeNull();
-        a(result.get("randomNumber")).shouldNotBeNull();
-        a(contentType()).shouldBeEqual("application/json");
-    }
-}

+ 66 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/DbControllerSpec.java

@@ -0,0 +1,66 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+package app.controllers;
+
+import org.junit.Test;
+
+import java.util.Map;
+import org.junit.Ignore;
+
+/**
+ * @author Igor Polevoy: 12/18/13 4:42 PM
+ * @author Eric Nielsen
+ */
+public class DbControllerSpec extends org.javalite.activeweb.DBControllerSpec {
+
+    @Test
+    public void shouldRenderOneRecord() {
+        //execute controller
+        request().get("index");
+        //process result
+        System.out.println(responseContent());
+        Map result = JsonHelper.toMap(responseContent());
+        //test result
+        a(result.size()).shouldBeEqual(2);
+        a(result.get("id")).shouldNotBeNull();
+        a(result.get("randomNumber")).shouldNotBeNull();
+        a(contentType()).shouldBeEqual("application/json");
+    }
+
+
+    @Test
+    public void shouldRenderOneRecordWithJackson() {
+        //execute controller
+        request().get("jackson");
+        //process result
+        System.out.println(responseContent());
+        Map result = JsonHelper.toMap(responseContent());
+        //test result
+        a(result.size()).shouldBeEqual(2);
+        a(result.get("id")).shouldNotBeNull();
+        a(result.get("randomNumber")).shouldNotBeNull();
+        a(contentType()).shouldBeEqual("application/json");
+    }
+
+    @Ignore
+    public void shouldRenderResponseOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}

+ 48 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/FortunesControllerSpec.java

@@ -0,0 +1,48 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package app.controllers;
+
+import org.javalite.activeweb.DBControllerSpec;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Eric Nielsen
+ */
+public class FortunesControllerSpec extends DBControllerSpec {
+
+    @Test
+    public void shouldRenderHtml() {
+        request().integrateViews().get("index");
+        System.out.print(responseContent());
+        the(responseContent()).shouldContain(
+                "<tr><td>11</td><td>&lt;script&gt;alert(&quot;This should not be displayed in a browser alert box.&quot;);&lt;/script&gt;</td></tr>"
+                + "<tr><td>4</td><td>A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1</td></tr>"
+                + "<tr><td>5</td><td>A computer program does what you tell it to do, not what you want it to do.</td></tr>"
+                + "<tr><td>2</td><td>A computer scientist is someone who fixes things that aren&apos;t broken.</td></tr>");
+    }
+
+    @Ignore
+    @Test
+    public void shouldRenderHtmlOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().integrateViews().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}

+ 33 - 26
frameworks/Java/activeweb/src/test/java/app/controllers/JsonControllerSpec.java

@@ -1,45 +1,52 @@
 /*
-Copyright 2009-2010 Igor Polevoy 
+Copyright 2009-2015 Igor Polevoy
 
-Licensed under the Apache License, Version 2.0 (the "License"); 
-you may not use this file except in compliance with the License. 
-You may obtain a copy of the License at 
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
 
-http://www.apache.org/licenses/LICENSE-2.0 
+http://www.apache.org/licenses/LICENSE-2.0
 
-Unless required by applicable law or agreed to in writing, software 
-distributed under the License is distributed on an "AS IS" BASIS, 
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-See the License for the specific language governing permissions and 
-limitations under the License. 
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
 */
-
-/**
- * @author Igor Polevoy: 12/18/13 3:59 PM
- */
-
 package app.controllers;
 
-import org.javalite.activeweb.Configuration;
 import org.javalite.activeweb.ControllerSpec;
+import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Map;
 
+/**
+ * @author Igor Polevoy: 12/18/13 3:59 PM
+ * @author Eric Nielsen
+ */
 public class JsonControllerSpec extends ControllerSpec {
 
     @Test
     public void shouldRenderMessage() {
+        request().integrateViews().get("index");
+        the(responseContent()).shouldBeEqual("{\"message\":\"Hello, World!\"}");
+        the(contentType()).shouldBeEqual("application/json");
+    }
 
-        System.out.println("ACTIVE_ENV value ============>>>>" + Configuration.getEnv());
-        //execute controller
-        request().get("index");
-
-        //process result
-        Map result = JsonHelper.toMap(responseContent());
+    @Test
+    public void shouldRenderMessageWithJackson() {
+        request().get("jackson");
+        the(responseContent()).shouldBeEqual("{\"message\":\"Hello, World!\"}");
+        the(contentType()).shouldBeEqual("application/json");
+    }
 
-        //test result
-        a(result.get("message")).shouldBeEqual("Hello, World!");
-        a(contentType()).shouldBeEqual("application/json");
+    @Ignore
+    @Test
+    public void shouldRenderMessageOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().integrateViews().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
     }
 }

+ 42 - 0
frameworks/Java/activeweb/src/test/java/app/controllers/PlaintextControllerSpec.java

@@ -0,0 +1,42 @@
+/*
+Copyright 2009-2015 Igor Polevoy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package app.controllers;
+
+import org.javalite.activeweb.ControllerSpec;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author Eric Nielsen
+ */
+public class PlaintextControllerSpec extends ControllerSpec {
+
+    @Test
+    public void shouldRenderResponse() {
+        request().get("index");
+        the(responseContent()).shouldBeEqual("Hello, World!");
+    }
+
+    @Ignore
+    public void shouldRenderHtmlOneMinute() {
+        long endMillis = System.currentTimeMillis() + 60*1000;
+        do {
+            request().get("index");
+            responseContent();
+        } while (System.currentTimeMillis() < endMillis);
+    }
+}

+ 3 - 3
frameworks/Java/curacao/build.sbt

@@ -13,9 +13,9 @@ resolvers ++= Seq(
 )
 
 libraryDependencies ++= Seq(
-  "com.kolich.curacao" % "curacao" % "2.6.3" % "compile",
-  "com.kolich.curacao" % "curacao-gson" % "2.6.3" % "compile",
-  "org.eclipse.jetty" % "jetty-webapp" % "9.2.3.v20140905" % "compile",
+  "com.kolich.curacao" % "curacao" % "2.9-M1" % "compile",
+  "com.kolich.curacao" % "curacao-gson" % "2.9-M1" % "compile",
+  "org.eclipse.jetty" % "jetty-webapp" % "9.2.9.v20150224" % "compile",
   "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
   "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
   "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",

+ 2 - 2
frameworks/Java/curacao/src/main/java/benchmark/Benchmarks.java

@@ -2,8 +2,8 @@ package benchmark;
 
 import benchmark.entities.HelloWorld;
 import com.kolich.curacao.annotations.Controller;
-import com.kolich.curacao.annotations.methods.RequestMapping;
-import com.kolich.curacao.handlers.requests.matchers.AntPathMatcher;
+import com.kolich.curacao.annotations.RequestMapping;
+import com.kolich.curacao.mappers.request.matchers.AntPathMatcher;
 
 @Controller
 public final class Benchmarks {

+ 3 - 3
frameworks/Java/gemini/benchmark_config

@@ -37,7 +37,7 @@
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "gemini",
+      "display_name": "gemini-mysql",
       "notes": "",
       "versus": "servlet"
     },
@@ -50,7 +50,7 @@
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",
-      "database": "MySQL",
+      "database": "Postgres",
       "framework": "gemini",
       "language": "Java",
       "orm": "Micro",
@@ -58,7 +58,7 @@
       "webserver": "Resin",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "gemini",
+      "display_name": "gemini-postgres",
       "notes": "",
       "versus": "servlet"
     }   

+ 3 - 3
frameworks/Java/netty/pom.xml

@@ -8,17 +8,17 @@
 	<version>0.1</version>
 
 	<packaging>jar</packaging>
-
+	
 	<dependencies>
 		<dependency>
 			<groupId>io.netty</groupId>
 			<artifactId>netty-codec-http</artifactId>
-			<version>4.0.25.Final</version>
+			<version>4.0.26.Final</version>
 		</dependency>
 		<dependency>
 			<groupId>io.netty</groupId>
 			<artifactId>netty-transport-native-epoll</artifactId>
-			<version>4.0.25.Final</version>
+			<version>4.0.26.Final</version>
 			<classifier>linux-x86_64</classifier>
 		</dependency>
 		<dependency>

+ 8 - 1
frameworks/Java/netty/src/main/java/hello/HelloWebServer.java

@@ -1,5 +1,7 @@
 package hello;
 
+import java.net.InetSocketAddress;
+
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.channel.Channel;
@@ -38,6 +40,8 @@ public class HelloWebServer {
 
     private void doRun(EventLoopGroup loupGroup, Class<? extends ServerChannel> serverChannelClass) throws InterruptedException {
 	try {
+		InetSocketAddress inet = new InetSocketAddress(port);
+		
 	    ServerBootstrap b = new ServerBootstrap();
 	    b.option(ChannelOption.SO_BACKLOG, 1024);
 	    b.option(ChannelOption.SO_REUSEADDR, true);
@@ -47,7 +51,10 @@ public class HelloWebServer {
 	    b.childOption(ChannelOption.SO_REUSEADDR, true);
 	    b.childOption(ChannelOption.MAX_MESSAGES_PER_READ, Integer.MAX_VALUE);
 
-	    Channel ch = b.bind(port).sync().channel();
+	    Channel ch = b.bind(inet).sync().channel();
+	    
+	    System.out.printf("Httpd started. Listening on: %s%n", inet.toString());	    
+	    
 	    ch.closeFuture().sync();
 	} finally {
 	    loupGroup.shutdownGracefully().sync();

+ 8 - 1
frameworks/Java/play2-java/setup_java.sh

@@ -1,5 +1,12 @@
 #!/bin/bash
 
 cd play2-java
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-java/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-java/target/universal/stage/RUNNING_PID
+fi
+
 ${IROOT}/sbt/bin/sbt stage
-target/universal/stage/bin/play2-java &
+target/universal/stage/bin/play2-java &

+ 8 - 1
frameworks/Java/play2-java/setup_java_ebean_bonecp.sh

@@ -1,5 +1,12 @@
 #!/bin/bash
 
 cd play2-java-ebean-bonecp
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-java-ebean-bonecp/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-java-ebean-bonecp/target/universal/stage/RUNNING_PID
+fi
+
 ${IROOT}/sbt/bin/sbt stage
-target/universal/stage/bin/play2-java-ebean-bonecp &
+target/universal/stage/bin/play2-java-ebean-bonecp &

+ 8 - 1
frameworks/Java/play2-java/setup_java_ebean_hikaricp.sh

@@ -1,5 +1,12 @@
 #!/bin/bash
 
 cd play2-java-ebean-hikaricp
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-java-ebean-hikaricp/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-java-ebean-hikaricp/target/universal/stage/RUNNING_PID
+fi
+
 ${IROOT}/sbt/bin/sbt stage
-target/universal/stage/bin/play2-java-ebean-hikaricp &
+target/universal/stage/bin/play2-java-ebean-hikaricp &

+ 8 - 1
frameworks/Java/play2-java/setup_java_jpa_bonecp.sh

@@ -1,5 +1,12 @@
 #!/bin/bash
 
 cd play2-java-jpa-bonecp
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-java-jpa-bonecp/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-java-jpa-bonecp/target/universal/stage/RUNNING_PID
+fi
+
 ${IROOT}/sbt/bin/sbt stage
-target/universal/stage/bin/play2-java-jpa-bonecp &
+target/universal/stage/bin/play2-java-jpa-bonecp &

+ 8 - 1
frameworks/Java/play2-java/setup_java_jpa_hikaricp.sh

@@ -1,5 +1,12 @@
 #!/bin/bash
 
 cd play2-java-jpa-hikaricp
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-java-jpa-hikaricp/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-java-jpa-hikaricp/target/universal/stage/RUNNING_PID
+fi
+
 ${IROOT}/sbt/bin/sbt stage
-target/universal/stage/bin/play2-java-jpa-hikaricp &
+target/universal/stage/bin/play2-java-jpa-hikaricp &

+ 1 - 1
frameworks/Java/servlet/pom.xml

@@ -20,7 +20,7 @@
 	<dependency>
 	    <groupId>org.postgresql</groupId>
 	    <artifactId>postgresql</artifactId>
-	    <version>9.3-1102-jdbc41</version>
+	    <version>9.4-1200-jdbc41</version>
 	</dependency>
             
 

+ 2 - 1
frameworks/Java/servlet3-cass/bash_profile.sh

@@ -1,2 +1,3 @@
-export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
+export JAVA_HOME=/opt/java8
+export JAVA_EXE=$JAVA_HOME/bin/java
 export RESIN_HOME=${IROOT}/resin-4.0.41

+ 1 - 1
frameworks/Java/servlet3-cass/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends java resin maven
+fw_depends java8 resin maven

+ 5 - 5
frameworks/Java/servlet3-cass/pom.xml

@@ -10,7 +10,7 @@
         <sourceEncoding>UTF-8</sourceEncoding>
         <java.version>1.7</java.version>
 
-        <slf4j.version>1.7.7</slf4j.version>
+        <slf4j.version>1.7.10</slf4j.version>
         <logback.version>1.1.2</logback.version>
     </properties>
 
@@ -22,7 +22,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
+                <version>3.2</version>
                 <configuration>
                     <source>${java.version}</source>
                     <target>${java.version}</target>
@@ -33,7 +33,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
-                <version>2.4</version>
+                <version>2.6</version>
                 <configuration>
                     <failOnMissingWebXml>false</failOnMissingWebXml>
                 </configuration>
@@ -62,13 +62,13 @@
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
-            <version>2.4.1</version>
+            <version>2.5.1</version>
         </dependency>
 
         <dependency>
             <groupId>com.datastax.cassandra</groupId>
             <artifactId>cassandra-driver-core</artifactId>
-            <version>2.0.3</version>
+            <version>2.1.4</version>
             <scope>compile</scope>
         </dependency>
 

+ 0 - 2
frameworks/Java/servlet3-cass/source_code

@@ -4,8 +4,6 @@
 ./servlet3-cass/src/main/java/fi/markoa
 ./servlet3-cass/src/main/java/fi/markoa/tfb
 ./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3
-./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3/AsyncErrorServlet1.java
-./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3/AsyncErrorServlet2.java
 ./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3/DatabaseBaseServlet.java
 ./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3/DatabaseQueriesServlet.java
 ./servlet3-cass/src/main/java/fi/markoa/tfb/servlet3/DatabaseQueryServlet.java

+ 2 - 2
frameworks/Java/spring/README.md

@@ -61,8 +61,8 @@ Check out [SampleApplication, the main Application file](src/main/java/com/teche
 ## Infrastructure Software Versions
 The tests were run with:
 
-* [Spring 4.1.3.RELEASE](http://projects.spring.io/spring-framework/)
-* [Spring Boot 1.2.0.RELEASE](http://projects.spring.io/spring-boot/)
+* [Spring 4.1.4.RELEASE](http://projects.spring.io/spring-framework/)
+* [Spring Boot 1.2.1.RELEASE](http://projects.spring.io/spring-boot/)
 * [Spring Data JPA 1.7.1.RELEASE](http://projects.spring.io/spring-data-jpa/)
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
 * [Undertow 1.1.1.Final](http://undertow.io/)

+ 1 - 1
frameworks/Java/spring/pom.xml

@@ -8,7 +8,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.2.0.RELEASE</version>
+        <version>1.2.1.RELEASE</version>
     </parent>
 
     <groupId>com.techempower</groupId>

+ 26 - 0
frameworks/Java/spring/src/main/java/com/techempower/spring/SampleApplication.java

@@ -1,9 +1,16 @@
 package com.techempower.spring;
 
+import io.undertow.Undertow;
+import io.undertow.UndertowOptions;
+import org.xnio.Options;
+
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
 import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer;
+import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
 import org.springframework.boot.context.web.SpringBootServletInitializer;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
@@ -21,4 +28,23 @@ public class SampleApplication extends SpringBootServletInitializer {
 		new SpringApplicationBuilder(SampleApplication.class).run(args);
 	}
 
+	@Bean
+	public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
+		UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
+		factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
+
+			@Override
+			public void customize(Undertow.Builder builder) {
+				builder.setBufferSize(1024 * 16)
+						.setIoThreads(Runtime.getRuntime().availableProcessors() * 2)
+						.setSocketOption(Options.BACKLOG, 10000)
+						.setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)
+						.setServerOption(UndertowOptions.ALWAYS_SET_DATE, true)
+						.setWorkerThreads(200);
+			}
+
+		});
+		return factory;
+	}
+
 }

+ 1 - 1
frameworks/Java/undertow-edge/pom.xml

@@ -45,7 +45,7 @@
         <dependency>
             <groupId>org.postgresql</groupId>
 	    <artifactId>postgresql</artifactId>
-            <version>9.3-1102-jdbc41</version>
+            <version>9.4-1200-jdbc41</version>
 	</dependency>
         <dependency>
             <groupId>org.mongodb</groupId>

+ 1 - 1
frameworks/Java/undertow/pom.xml

@@ -36,7 +36,7 @@
         <dependency>
             <groupId>org.postgresql</groupId>
 	    <artifactId>postgresql</artifactId>
-            <version>9.3-1102-jdbc41</version>
+            <version>9.4-1200-jdbc41</version>
 	</dependency>
         <dependency>
             <groupId>org.mongodb</groupId>

+ 2 - 0
frameworks/Java/wildfly-ee7/benchmark_config

@@ -3,6 +3,8 @@
   "tests": [{
     "mysql" : {
       "setup_file": "setup",
+      "json_url": "/wildfly-ee7/rest/json",
+      "plaintext_url": "/wildfly-ee7/rest/plaintext",
       "db_url": "/wildfly-ee7/rest/db",
       "query_url": "/wildfly-ee7/rest/queries?queries=",
       "fortune_url": "/wildfly-ee7/fortunes.xhtml",

+ 2 - 2
frameworks/Java/wildfly-ee7/pom.xml

@@ -12,8 +12,8 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<version.compiler.plugin>3.1</version.compiler.plugin>
 		<version.war.plugin>2.4</version.war.plugin>
-		<version.wildfly>8.1.0.Final</version.wildfly>
-		<version.mysql.connector>5.1.29</version.mysql.connector>
+		<version.wildfly>8.2.0.Final</version.wildfly>
+		<version.mysql.connector>5.1.34</version.mysql.connector>
 		<version.javaee.api>7.0</version.javaee.api>
 		<version.jboss.spec.javaee.7.0>1.0.0.Final</version.jboss.spec.javaee.7.0>
 	</properties>

+ 1 - 1
frameworks/Java/wildfly-ee7/server-resources/datasources/mysql-ds.xml

@@ -2,7 +2,7 @@
 <datasources xmlns="http://www.jboss.org/ironjacamar/schema">
     <datasource jta="true" jndi-name="java:jboss/datasources/helloWorld" pool-name="MySqlDS" enabled="true" use-java-context="true" use-ccm="true">
 		<connection-url>jdbc:mysql://${database.host}:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;traceProtocol=false&amp;useServerPrepStmts=true&amp;enableQueryTimeouts=false&amp;useUnbufferedIO=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;cacheRSMetadata=true</connection-url>
-		<driver>mysql-connector-java-${version.mysql.connector}.jar</driver>
+		<driver>mysql-connector-java-${version.mysql.connector}.jar_com.mysql.jdbc.Driver_5_1</driver>
 		<pool>
 		    <prefill>false</prefill>
 		    <min-pool-size>32</min-pool-size>

+ 1 - 1
frameworks/Java/wildfly-ee7/setup.sh

@@ -3,4 +3,4 @@
 export JAVA_OPTS="-Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=25 -verbosegc -Xloggc:/tmp/wildfly_gc.log"
 
 mvn clean initialize package -Pbenchmark -Ddatabase.host=${DBHOST}
-target/wildfly-8.1.0.Final/bin/standalone.sh -b 0.0.0.0 &
+target/wildfly-8.2.0.Final/bin/standalone.sh -b 0.0.0.0 &

+ 8 - 17
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/jpa/PersistenceResources.java

@@ -1,27 +1,18 @@
 package com.techempower.ee7.jpa;
 
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Disposes;
+import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
 import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
-import javax.persistence.SynchronizationType;
+import javax.persistence.PersistenceContext;
 
 public class PersistenceResources {
 
-  @PersistenceUnit
-  private EntityManagerFactory entityManagerFactory;
+    @PersistenceContext
+    private EntityManager em;
 
-  @Produces
-  @RequestScoped
-  public EntityManager entityManager() {
-    return entityManagerFactory.createEntityManager(SynchronizationType.UNSYNCHRONIZED);
-  }
-
-  protected void closeEntityManager(@Disposes EntityManager entityManager) {
-    if (entityManager.isOpen()) {
-      entityManager.close();
+    @Produces
+    @Dependent
+    public EntityManager entityManager() {
+        return em;
     }
-  }
 }

+ 6 - 8
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/rest/CatchAllExceptionMapper.java

@@ -1,6 +1,5 @@
 package com.techempower.ee7.rest;
 
-import javax.inject.Inject;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -11,12 +10,11 @@ import org.jboss.logging.Logger;
 @Provider
 public class CatchAllExceptionMapper implements ExceptionMapper<Exception> {
 
-  @Inject
-  private Logger log;
+    static final Logger log = Logger.getLogger(CatchAllExceptionMapper.class);
 
-  @Override
-  public Response toResponse(Exception exception) {
-    log.info("Request Failed: " + exception.getMessage());
-    return Response.status(Status.BAD_REQUEST).build();
-  }
+    @Override
+    public Response toResponse(Exception exception) {
+        log.info("Request Failed: " + exception.getMessage());
+        return Response.status(Status.BAD_REQUEST).build();
+    }
 }

+ 34 - 36
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/tests/Updates.java

@@ -21,41 +21,39 @@ import com.techempower.ee7.util.Helpers;
 @Path("/updates")
 public class Updates {
 
-  private static final int MIN_QUERIES = 1;
-  private static final int MAX_QUERIES = 500;
-
-  @Inject
-  private EntityManager em;
-
-  @Inject
-  private Logger log;
-
-  @Transactional
-  @GET
-  @Produces(MediaType.APPLICATION_JSON)
-  public List<World> update(@QueryParam("queries") final String queries) {
-    final int iterations =
-        Helpers.boundedIntegerFromNullableString(queries, MIN_QUERIES, MAX_QUERIES);
-
-    List<World> worlds = new ArrayList<>(iterations);
-
-    for (int i = 0; i < iterations; i++) {
-      int id = Helpers.randomWorldId();
-      worlds.add(em.find(World.class, id));
-    }
-
-    for (World w : worlds) {
-      w.getRandomNumber(); // Mandatory to read for the test
-      w.setRandomNumber(Helpers.randomWorldId());
-    }
-
-    try {
-      em.joinTransaction();
-      em.flush();
-    } catch (PersistenceException e) {
-      log.info("Failed to flush changes to database.");
-      throw e;
+    private static final Logger log = Logger.getLogger(Updates.class);
+
+    private static final int MIN_QUERIES = 1;
+    private static final int MAX_QUERIES = 500;
+
+    @Inject
+    private EntityManager em;
+
+    @Transactional
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public List<World> update(@QueryParam("queries") final String queries) {
+        final int iterations = Helpers.boundedIntegerFromNullableString(queries, MIN_QUERIES, MAX_QUERIES);
+
+        List<World> worlds = new ArrayList<>(iterations);
+
+        for (int i = 0; i < iterations; i++) {
+            int id = Helpers.randomWorldId();
+            worlds.add(em.find(World.class, id));
+        }
+
+        for (World w : worlds) {
+            w.getRandomNumber(); // Mandatory to read for the test
+            w.setRandomNumber(Helpers.randomWorldId());
+        }
+
+        try {
+            em.flush();
+        }
+        catch (PersistenceException e) {
+            log.info("Failed to flush changes to database.");
+            throw e;
+        }
+        return worlds;
     }
-    return worlds;
-  }
 }

+ 28 - 27
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/Helpers.java

@@ -4,33 +4,34 @@ import java.util.concurrent.ThreadLocalRandom;
 
 public class Helpers {
 
-  /**
-   * Random number between 1 and 10,000
-   * 
-   * @return
-   */
-  public static int randomWorldId() {
-    return ThreadLocalRandom.current().nextInt(1, 10001);
-  }
+    /**
+     * Random number between 1 and 10,000
+     * 
+     * @return
+     */
+    public static int randomWorldId() {
+        return ThreadLocalRandom.current().nextInt(1, 10001);
+    }
 
-  /**
-   * Returns a bounded integer. min if null or less than bounds. max if greater than bounds
-   * 
-   * @param value
-   * @param min
-   * @param max
-   * @return
-   */
-  public static int boundedIntegerFromNullableString(final String value, final int min,
-      final int max) {
-    if (value == null) {
-      return min;
-    } else {
-      try {
-        return Math.min(max, Math.max(min, Integer.parseInt(value)));
-      } catch (NumberFormatException e) {
-        return min;
-      }
+    /**
+     * Returns a bounded integer. min if null or less than bounds. max if greater than bounds
+     * 
+     * @param value
+     * @param min
+     * @param max
+     * @return
+     */
+    public static int boundedIntegerFromNullableString(final String value, final int min, final int max) {
+        if (value == null) {
+            return min;
+        }
+        else {
+            try {
+                return Math.min(max, Math.max(min, Integer.parseInt(value)));
+            }
+            catch (NumberFormatException e) {
+                return min;
+            }
+        }
     }
-  }
 }

+ 0 - 15
frameworks/Java/wildfly-ee7/src/main/java/com/techempower/ee7/util/LoggerProducer.java

@@ -1,15 +0,0 @@
-package com.techempower.ee7.util;
-
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-
-import org.jboss.logging.Logger;
-
-public class LoggerProducer {
-
-  @Produces
-  Logger produceLog(InjectionPoint injectionPoint) {
-    return Logger.getLogger(injectionPoint.getBean() != null ? injectionPoint.getBean()
-        .getBeanClass() : injectionPoint.getMember().getDeclaringClass());
-  }
-}

+ 1 - 1
frameworks/PHP/hhvm/setup_hhvm.sh

@@ -8,5 +8,5 @@ sed -i 's|File = .*/error.log|File = '"${TROOT}"'/error.log|g' deploy/config.hdf
 sed -i "s|/usr/local/nginx/|${IROOT}/nginx/|g" deploy/nginx.conf
 sed -i "s|TEST_ROOT|${TROOT}|g" deploy/nginx.conf
 
-hhvm --config $TROOT/deploy/config.hdf -m daemon
+hhvm --config $TROOT/deploy/config.hdf --user $(whoami) -m daemon
 $NGINX_HOME/sbin/nginx -c $TROOT/deploy/nginx.conf

+ 15 - 36
frameworks/Perl/mojolicious/app.pl

@@ -1,5 +1,5 @@
 use Mojolicious::Lite;
-use Mango;
+use Mojo::Pg;
 
 use JSON::XS 'encode_json';
 use Scalar::Util 'looks_like_number';
@@ -23,14 +23,8 @@ plugin Config => {
   @{app->config->{hypnotoad}}{keys %$merge} = values %$merge;
 }
 
-# Database connections
 
-helper mango   => sub { state $mango = Mango->new('mongodb://'. shift->config->{database_host}) };
-helper db      => sub { state $db = shift->mango->db('hello_world') };
-helper world   => sub { state $world = shift->db->collection('world') };
-helper fortune => sub { state $fortune = shift->db->collection('fortune') };
-
-# JSON::XS renderer
+helper pg => sub { state $pg = Mojo::Pg->new('postgresql://benchmarkdbuser:benchmarkdbpass@' . shift->config->{database_host} . '/hello_world') };
 
 helper render_json => sub { shift->render( data => encode_json(shift), format => 'json' ) }; 
 
@@ -46,13 +40,10 @@ get '/queries' => sub {
 };
 
 get '/fortunes' => sub {
-  my $c = shift->render_later;
-  my $tx = $c->tx;
-  $c->helpers->fortune->find->all(sub{
-    my ($cursor, $err, $docs) = @_;
-    push @$docs, { _id => 0, message => 'Additional fortune added at request time.' };
-    $c->render( fortunes => docs => $docs ) unless $tx->is_finished;
-  });
+  my $c = shift;
+  my $docs = $c->helpers->pg->db->query('SELECT id, message FROM Fortune')->arrays;
+  push @$docs, [0, 'Additional fortune added at request time.'];
+  $c->render( fortunes => docs => $docs->sort(sub{ $a->[1] cmp $b->[1] }) );
 };
 
 get '/updates' => sub {
@@ -69,8 +60,6 @@ helper 'render_query' => sub {
   $args ||= {};
   my $update = $args->{update};
 
-  $self->render_later;
-
   $q = 1 unless looks_like_number($q);
   $q = 1   if $q < 1;
   $q = 500 if $q > 500;
@@ -78,27 +67,17 @@ helper 'render_query' => sub {
   my $r  = [];
   my $tx = $self->tx;
 
-  my $delay = Mojo::IOLoop->delay;
-  $delay->on(finish => sub{
-    $r = $r->[0] if $args->{single};
-    $self->helpers->render_json($r) unless $tx->is_finished;
-  });
-
-  my $world = $self->helpers->world;
+  my $db = $self->helpers->pg->db;
 
   foreach (1 .. $q) {
     my $id = int rand 10_000;
-    my $end = $delay->begin;
-    $world->find_one({_id => $id} => sub {
-      my ($world, $err, $doc) = @_;
-      if ($update) { $doc->{randomNumber} = 1 + int rand 10_000 };
-      push @$r, { id => $id, randomNumber => $doc->{randomNumber} };
-      $update ? $world->save($doc, $end) : $end->();
-    });
+    my $randomNumber = $db->query('SELECT randomnumber FROM World WHERE id=?', $id)->array->[0];
+    $db->query('UPDATE World SET randomnumber=? WHERE id=?', ($randomNumber = 1 + int rand 10_000), $id) if $update; 
+    push @$r, { id => $id, randomNumber => $randomNumber };
   }
 
-  # use this line if not running under a Mojolicious server
-  # $delay->wait unless $delay->ioloop->is_running;
+  $r = $r->[0] if $args->{single};
+  $self->helpers->render_json($r);
 };
 
 app->start;
@@ -112,10 +91,10 @@ __DATA__
   <body>
     <table>
       <tr><th>id</th><th>message</th></tr>
-      % foreach my $doc (sort { $a->{message} cmp $b->{message} } @$docs) {
+      % foreach my $doc (@$docs) {
         <tr>
-          <td><%= $doc->{_id}     %></td>
-          <td><%= $doc->{message} %></td>
+          <td><%= $doc->[0] %></td>
+          <td><%= $doc->[1] %></td>
         </tr>
       % }
     </table>

+ 2 - 2
frameworks/Perl/mojolicious/benchmark_config

@@ -11,8 +11,8 @@
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
-      "classification": "Full",
-      "database": "MongoDB",
+      "classification": "Fullstack",
+      "database": "Postgres",
       "framework": "mojolicious",
       "language": "Perl",
       "orm": "Raw",

+ 2 - 2
frameworks/Perl/mojolicious/cpanfile

@@ -1,5 +1,5 @@
-requires 'Mojolicious', '>= 5.29';
-requires 'Mango', '>= 1.0';
+requires 'Mojolicious', '>= 6.02';
+requires 'Mojo::Pg', '>= 1.14';
 requires 'JSON::XS';
 requires 'EV';
 

+ 120 - 25
frameworks/Perl/mojolicious/cpanfile.snapshot

@@ -1,5 +1,112 @@
 # carton snapshot format: version 1.0
 DISTRIBUTIONS
+  DBD-Pg-3.5.1
+    pathname: T/TU/TURNSTEP/DBD-Pg-3.5.1.tar.gz
+    provides:
+      Bundle::DBD::Pg v3.5.1
+      DBD::Pg v3.5.1
+    requirements:
+      DBI 1.614
+      ExtUtils::MakeMaker 6.11
+      Test::More 0.88
+      Time::HiRes 0
+      version 0
+  DBI-1.633
+    pathname: T/TI/TIMB/DBI-1.633.tar.gz
+    provides:
+      Bundle::DBI 12.008696
+      DBD::DBM 0.08
+      DBD::DBM::Statement 0.08
+      DBD::DBM::Table 0.08
+      DBD::DBM::db 0.08
+      DBD::DBM::dr 0.08
+      DBD::DBM::st 0.08
+      DBD::ExampleP 12.014311
+      DBD::ExampleP::db 12.014311
+      DBD::ExampleP::dr 12.014311
+      DBD::ExampleP::st 12.014311
+      DBD::File 0.44
+      DBD::File::DataSource::File 0.44
+      DBD::File::DataSource::Stream 0.44
+      DBD::File::Statement 0.44
+      DBD::File::Table 0.44
+      DBD::File::TableSource::FileSystem 0.44
+      DBD::File::db 0.44
+      DBD::File::dr 0.44
+      DBD::File::st 0.44
+      DBD::Gofer 0.015327
+      DBD::Gofer::Policy::Base 0.010088
+      DBD::Gofer::Policy::classic 0.010088
+      DBD::Gofer::Policy::pedantic 0.010088
+      DBD::Gofer::Policy::rush 0.010088
+      DBD::Gofer::Transport::Base 0.014121
+      DBD::Gofer::Transport::corostream undef
+      DBD::Gofer::Transport::null 0.010088
+      DBD::Gofer::Transport::pipeone 0.010088
+      DBD::Gofer::Transport::stream 0.014599
+      DBD::Gofer::db 0.015327
+      DBD::Gofer::dr 0.015327
+      DBD::Gofer::st 0.015327
+      DBD::NullP 12.014715
+      DBD::NullP::db 12.014715
+      DBD::NullP::dr 12.014715
+      DBD::NullP::st 12.014715
+      DBD::Proxy 0.2004
+      DBD::Proxy::RPC::PlClient 0.2004
+      DBD::Proxy::db 0.2004
+      DBD::Proxy::dr 0.2004
+      DBD::Proxy::st 0.2004
+      DBD::Sponge 12.010003
+      DBD::Sponge::db 12.010003
+      DBD::Sponge::dr 12.010003
+      DBD::Sponge::st 12.010003
+      DBDI 12.015129
+      DBI 1.633
+      DBI::Const::GetInfo::ANSI 2.008697
+      DBI::Const::GetInfo::ODBC 2.011374
+      DBI::Const::GetInfoReturn 2.008697
+      DBI::Const::GetInfoType 2.008697
+      DBI::DBD 12.015129
+      DBI::DBD::Metadata 2.014214
+      DBI::DBD::SqlEngine 0.06
+      DBI::DBD::SqlEngine::DataSource 0.06
+      DBI::DBD::SqlEngine::Statement 0.06
+      DBI::DBD::SqlEngine::Table 0.06
+      DBI::DBD::SqlEngine::TableSource 0.06
+      DBI::DBD::SqlEngine::TieMeta 0.06
+      DBI::DBD::SqlEngine::TieTables 0.06
+      DBI::DBD::SqlEngine::db 0.06
+      DBI::DBD::SqlEngine::dr 0.06
+      DBI::DBD::SqlEngine::st 0.06
+      DBI::FAQ 1.014935
+      DBI::Gofer::Execute 0.014283
+      DBI::Gofer::Request 0.012537
+      DBI::Gofer::Response 0.011566
+      DBI::Gofer::Serializer::Base 0.009950
+      DBI::Gofer::Serializer::DataDumper 0.009950
+      DBI::Gofer::Serializer::Storable 0.015586
+      DBI::Gofer::Transport::Base 0.012537
+      DBI::Gofer::Transport::pipeone 0.012537
+      DBI::Gofer::Transport::stream 0.012537
+      DBI::Profile 2.015065
+      DBI::ProfileData 2.010008
+      DBI::ProfileDumper 2.015325
+      DBI::ProfileDumper::Apache 2.014121
+      DBI::ProfileSubs 0.009396
+      DBI::ProxyServer 0.3005
+      DBI::ProxyServer::db 0.3005
+      DBI::ProxyServer::dr 0.3005
+      DBI::ProxyServer::st 0.3005
+      DBI::SQL::Nano 1.015544
+      DBI::SQL::Nano::Statement_ 1.015544
+      DBI::SQL::Nano::Table_ 1.015544
+      DBI::Util::CacheMemory 0.010315
+      DBI::Util::_accessor 0.009479
+      DBI::common 1.633
+    requirements:
+      ExtUtils::MakeMaker 6.48
+      Test::Simple 0.90
+      perl 5.008
   EV-4.18
     pathname: M/ML/MLEHMANN/EV-4.18.tar.gz
     provides:
@@ -24,34 +131,22 @@ DISTRIBUTIONS
       ExtUtils::MakeMaker 0
       Types::Serialiser 0
       common::sense 0
-  Mango-1.16
-    pathname: O/OD/ODC/Mango-1.16.tar.gz
+  Mojo-Pg-1.14
+    pathname: S/SR/SRI/Mojo-Pg-1.14.tar.gz
     provides:
-      Mango 1.16
-      Mango::BSON undef
-      Mango::BSON::Binary undef
-      Mango::BSON::Code undef
-      Mango::BSON::Document undef
-      Mango::BSON::ObjectID undef
-      Mango::BSON::Time undef
-      Mango::BSON::Timestamp undef
-      Mango::BSON::_MaxKey undef
-      Mango::BSON::_MinKey undef
-      Mango::Bulk undef
-      Mango::Collection undef
-      Mango::Cursor undef
-      Mango::Cursor::Query undef
-      Mango::Database undef
-      Mango::GridFS undef
-      Mango::GridFS::Reader undef
-      Mango::GridFS::Writer undef
-      Mango::Protocol undef
+      Mojo::Pg 1.14
+      Mojo::Pg::Database undef
+      Mojo::Pg::Migrations undef
+      Mojo::Pg::PubSub undef
+      Mojo::Pg::Results undef
+      Mojo::Pg::Transaction undef
     requirements:
+      DBD::Pg 0
       ExtUtils::MakeMaker 0
-      Mojolicious 5.40
+      Mojolicious 6.0
       perl 5.010001
-  Mojolicious-5.81
-    pathname: S/SR/SRI/Mojolicious-5.81.tar.gz
+  Mojolicious-6.02
+    pathname: S/SR/SRI/Mojolicious-6.02.tar.gz
     provides:
       Mojo undef
       Mojo::Asset undef
@@ -114,7 +209,7 @@ DISTRIBUTIONS
       Mojo::UserAgent::Server undef
       Mojo::UserAgent::Transactor undef
       Mojo::Util undef
-      Mojolicious 5.81
+      Mojolicious 6.02
       Mojolicious::Command undef
       Mojolicious::Command::cgi undef
       Mojolicious::Command::cpanify undef

+ 1 - 0
frameworks/Perl/mojolicious/setup.sh

@@ -1,4 +1,5 @@
 #!/bin/bash
 
+export LIBEV_FLAGS=7
 HYPNOTOAD=$(${PERL_HOME}/bin/carton exec which hypnotoad)
 ${PERL_HOME}/bin/carton exec ${PERL_HOME}/bin/perl ${HYPNOTOAD} ${TROOT}/app.pl

+ 3 - 2
frameworks/Python/API-Hour/hello/etc/hello/main/main.yaml

@@ -1,3 +1,4 @@
+---
 engines:
   pg:
     host: 127.0.0.1
@@ -5,5 +6,5 @@ engines:
     dbname: hello_world
     user: benchmarkdbuser
     password: benchmarkdbpass
-    minsize: 40
-    maxsize: 40
+    minsize: 22
+    maxsize: 22

+ 16 - 22
frameworks/Python/API-Hour/hello/hello/services/world.py

@@ -14,35 +14,29 @@ def get_random_record(container):
 
 @asyncio.coroutine
 def get_random_records(container, limit):
-    tasks = []
+    pg = yield from container.engines['pg']
     results = []
-    for i in range(limit):
-        tasks.append(container.loop.create_task(get_random_record(container)))
-    yield from asyncio.wait(tasks)
-    for task in tasks:
-        results.append(task.result())
+    with (yield from pg.cursor()) as cur:
+        for i in range(limit):
+            yield from cur.execute('SELECT id AS "Id", randomnumber AS "RandomNumber" FROM world WHERE id=%(idx)s LIMIT 1',
+                                   {'idx': randint(1, 10000)})
+            results.append((yield from cur.fetchone()))
+
     return results
 
 @asyncio.coroutine
-def update_random_record(container):
+def update_random_records(container, limit):
+    results = []
     pg = yield from container.engines['pg']
 
-    world = yield from get_random_record(container)
-
     with (yield from pg.cursor()) as cur:
-        yield from cur.execute('UPDATE world SET randomnumber=%(random_number)s WHERE id=%(idx)s',
-                               {'random_number': randint(1, 10000), 'idx': world['Id']})
-    return world
-
[email protected]
-def update_random_records(container, limit):
-    tasks = []
-    results = []
-    for i in range(limit):
-        tasks.append(container.loop.create_task(update_random_record(container)))
-    yield from asyncio.wait(tasks)
-    for task in tasks:
-        results.append(task.result())
+        for i in range(limit):
+            yield from cur.execute('SELECT id AS "Id", randomnumber AS "RandomNumber" FROM world WHERE id=%(idx)s LIMIT 1',
+                                   {'idx': randint(1, 10000)})
+            world = yield from cur.fetchone()
+            yield from cur.execute('UPDATE world SET randomnumber=%(random_number)s WHERE id=%(idx)s',
+                                   {'random_number': randint(1, 10000), 'idx': world['Id']})
+            results.append(world)
     return results
 
 @asyncio.coroutine

+ 1 - 1
frameworks/Python/bottle/setup_nginxuwsgi.sh

@@ -3,4 +3,4 @@
 sed -i 's|include .*/conf/uwsgi_params;|include '"${NGINX_HOME}"'/conf/uwsgi_params;|g' nginx.conf
 
 ${NGINX_HOME}/sbin/nginx -c ${TROOT}/nginx.conf
-${PY2_ROOT}/bin/uwsgi -d ${ERR} --ini ${TROOT}/uwsgi.ini --processes ${MAX_THREADS} --wsgi app:app
+${PY2_ROOT}/bin/uwsgi --ini ${TROOT}/uwsgi.ini --processes ${MAX_THREADS} --wsgi app:app &

+ 1 - 1
frameworks/Python/flask/setup_nginxuwsgi.sh

@@ -3,4 +3,4 @@
 sed -i 's|include .*/conf/uwsgi_params;|include '"${NGINX_HOME}"'/conf/uwsgi_params;|g' nginx.conf
 
 $NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf
-${PY2_ROOT}/bin/uwsgi -d ${ERR} --ini ${TROOT}/uwsgi.ini --processes ${MAX_THREADS} --wsgi app:app
+${PY2_ROOT}/bin/uwsgi --ini ${TROOT}/uwsgi.ini --processes ${MAX_THREADS} --wsgi app:app &

+ 1 - 1
frameworks/Python/uwsgi/setup_nginx.sh

@@ -3,4 +3,4 @@
 sed -i 's|include .*/conf/uwsgi_params;|include '"${NGINX_HOME}"'/conf/uwsgi_params;|g' nginx.conf
 
 $NGINX_HOME/sbin/nginx -c ${TROOT}/nginx.conf
-$PY2_ROOT/bin/uwsgi -d ${ERR} --ini uwsgi.ini --processes ${MAX_THREADS} --gevent 1000 --wsgi hello
+$PY2_ROOT/bin/uwsgi --ini uwsgi.ini --processes ${MAX_THREADS} --gevent 1000 --wsgi hello &

+ 1 - 1
frameworks/Python/wsgi/setup_nginxuwsgi.sh

@@ -3,4 +3,4 @@
 sed -i 's|include .*/conf/uwsgi_params;|include '"${NGINX_HOME}"'/conf/uwsgi_params;|g' nginx.conf
 
 $NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf
-$PY2_ROOT/bin/uwsgi -d ${ERR} --ini uwsgi.ini --processes ${MAX_THREADS} --wsgi hello:app
+$PY2_ROOT/bin/uwsgi --ini uwsgi.ini --processes ${MAX_THREADS} --wsgi hello:app &

+ 11 - 4
frameworks/Ruby/grape/install.sh

@@ -2,13 +2,20 @@
 
 fw_depends rvm nginx java
 
-rvm install ruby-2.0.0-p0
-rvm ruby-2.0.0-p0 do bundle install --gemfile=$TROOT/Gemfile
+if [ "$TRAVIS" = "true" ]
+then
+	rvmsudo rvm install ruby-2.0.0-p0
+	rvmsudo rvm install jruby-1.7.8
+	rvmsudo rvm install rbx-2.2.10
+else
+	rvm install ruby-2.0.0-p0
+	rvm install jruby-1.7.8
+	rvm install rbx-2.2.10
+fi
 
-rvm install jruby-1.7.8
+rvm ruby-2.0.0-p0 do bundle install --gemfile=$TROOT/Gemfile --path vendor/bundle
 rvm jruby-1.7.8 do bundle install --gemfile=$TROOT/Gemfile
 
 export LC_ALL=en_US.UTF-8 
 export LANG=en_US.UTF-8
-rvm install rbx-2.2.10
 rvm rbx-2.2.10 do bundle install --gemfile=$TROOT/Gemfile

+ 6 - 1
frameworks/Ruby/grape/run_jruby_puma.sh

@@ -3,7 +3,12 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 

+ 6 - 1
frameworks/Ruby/grape/run_mri_puma.sh

@@ -3,7 +3,12 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 

+ 6 - 1
frameworks/Ruby/grape/run_rbx_puma.sh

@@ -3,7 +3,12 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 

+ 6 - 1
frameworks/Ruby/grape/run_thin.sh

@@ -3,7 +3,12 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 

+ 6 - 1
frameworks/Ruby/grape/run_torqbox.sh

@@ -3,7 +3,12 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 

+ 7 - 2
frameworks/Ruby/grape/run_trinidad.sh

@@ -3,8 +3,13 @@
 # We assume single-user installation as 
 # done in our rvm.sh script and 
 # in Travis-CI
-source $HOME/.rvm/scripts/rvm
+if [ "$TRAVIS" = "true" ]
+then
+	source /home/travis/.rvm/scripts/rvm
+else
+	source $HOME/.rvm/scripts/rvm
+fi
 
 sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
 
-rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml
+rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml &

Some files were not shown because too many files changed in this diff