Browse Source

enable DB test for silex-orm

Keith Newman 9 years ago
parent
commit
478fdaeaa6

+ 1 - 1
frameworks/PHP/silex-orm/benchmark_config.json

@@ -5,7 +5,7 @@
       "setup_file": "setup",
       "setup_file": "setup",
       "json_url": "/json",
       "json_url": "/json",
       "db_url": "/db",
       "db_url": "/db",
-      "query_url": "/db?queries=",
+      "query_url": "/queries?queries=",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Micro",
       "classification": "Micro",

+ 1 - 1
frameworks/PHP/silex-orm/setup.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends php nginx composer
+fw_depends php7 nginx composer
 
 
 sed -i 's|127.0.0.1|'"${DBHOST}"'|g' web/index.php
 sed -i 's|127.0.0.1|'"${DBHOST}"'|g' web/index.php
 sed -i 's|".*/FrameworkBenchmarks/php-silex-orm|"'"${TROOT}"'|g' deploy/php-silex-orm
 sed -i 's|".*/FrameworkBenchmarks/php-silex-orm|"'"${TROOT}"'|g' deploy/php-silex-orm

+ 9 - 4
frameworks/PHP/silex-orm/web/index.php

@@ -43,7 +43,16 @@ $app->get('/json', function() {
 });
 });
 
 
 $app->get('/db', function(Request $request) use ($app) {
 $app->get('/db', function(Request $request) use ($app) {
+    $repo = $app['orm.em']->getRepository('Entity\World');
+
+    $worlds =  $repo->find(mt_rand(1, 10000));
+
+    return new JsonResponse($worlds);
+});
+
+$app->get('/queries', function(Request $request) use ($app) {
     $queries = $request->query->getInt('queries', 1);
     $queries = $request->query->getInt('queries', 1);
+    $queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
     // possibility for micro enhancement could be the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
     // possibility for micro enhancement could be the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
     $worlds = array();
     $worlds = array();
     $repo = $app['orm.em']->getRepository('Entity\World');
     $repo = $app['orm.em']->getRepository('Entity\World');
@@ -52,10 +61,6 @@ $app->get('/db', function(Request $request) use ($app) {
         $worlds[] =  $repo->find(mt_rand(1, 10000));
         $worlds[] =  $repo->find(mt_rand(1, 10000));
     }
     }
 
 
-    if ($queries == 1) {
-        $worlds = $worlds[0];
-    }
-
     return new JsonResponse($worlds);
     return new JsonResponse($worlds);
 });
 });