Browse Source

Update Fuel query to pass the test (#4626)

Joan Miquel 6 years ago
parent
commit
4c527ce649

+ 1 - 1
frameworks/PHP/fuel/benchmark_config.json

@@ -4,7 +4,7 @@
     "default": {
     "default": {
       "json_url": "/json",
       "json_url": "/json",
       "db_url": "/db",
       "db_url": "/db",
-      "query_url": "/db?queries=",
+      "query_url": "/dbquery?queries=",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",

+ 9 - 4
frameworks/PHP/fuel/fuel/app/classes/controller/bench.php

@@ -10,6 +10,15 @@ class Controller_Bench extends Controller
     }
     }
 
 
     public function action_db()
     public function action_db()
+    {
+        $worlds = Model_World::find(mt_rand(1, 10000))->toJson();
+
+        return new Response(json_encode($worlds), 200, array(
+            'Content-Type' => 'application/json'
+        ));
+    }
+
+    public function action_dbquery()
     {
     {
         $queries = Input::get('queries', 1);
         $queries = Input::get('queries', 1);
         $queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
         $queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
@@ -20,10 +29,6 @@ class Controller_Bench extends Controller
             $worlds[] = Model_World::find(mt_rand(1, 10000))->toJson();
             $worlds[] = Model_World::find(mt_rand(1, 10000))->toJson();
         }
         }
 
 
-        if($queries == 1) {
-            $worlds = $worlds[0];
-        }
-
         return new Response(json_encode($worlds), 200, array(
         return new Response(json_encode($worlds), 200, array(
             'Content-Type' => 'application/json'
             'Content-Type' => 'application/json'
         ));
         ));

+ 1 - 0
frameworks/PHP/fuel/fuel/app/config/routes.php

@@ -6,5 +6,6 @@ return array(
 	'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
 	'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'),
     'json' => 'bench/json',
     'json' => 'bench/json',
     'db' => 'bench/db',
     'db' => 'bench/db',
+    'dbquery' => 'bench/dbquery',
     'fortunes' => 'bench/fortunes'
     'fortunes' => 'bench/fortunes'
 );
 );