Browse Source

the 'db' test always returns an object and the 'queries' test, an array

Kpacha 11 years ago
parent
commit
29991c9742

+ 2 - 2
php-phalcon/README.md

@@ -41,8 +41,8 @@ MongoDB: http://localhost/mongodb/db
 
 
 ### Variable Query Test
 ### Variable Query Test
     
     
-MySQL: http://localhost/db?queries=2
-MongoDB: http://localhost/mongodb/db?queries=2
+MySQL: http://localhost/queries?queries=2
+MongoDB: http://localhost/mongodb/queries?queries=2
 
 
 ### Update Test
 ### Update Test
     
     

+ 10 - 2
php-phalcon/app/config/routes.php

@@ -7,12 +7,16 @@ $router->add('/json', array(
     'action' => 'json',
     'action' => 'json',
 ));
 ));
 
 
-// Handles "/db" as well as "/db?queries={queries}"
 $router->add('/db', array(
 $router->add('/db', array(
     'controller' => 'bench',
     'controller' => 'bench',
     'action' => 'db',
     'action' => 'db',
 ));
 ));
 
 
+$router->add('/queries', array(
+    'controller' => 'bench',
+    'action' => 'queries',
+));
+
 $router->add('/fortunes', array(
 $router->add('/fortunes', array(
     'controller' => 'bench',
     'controller' => 'bench',
     'action' => 'fortunes',
     'action' => 'fortunes',
@@ -28,12 +32,16 @@ $router->add('/plaintext', array(
     'action' => 'plaintext',
     'action' => 'plaintext',
 ));
 ));
 
 
-// Handles "/db" as well as "/db?queries={queries}"
 $router->add('/mongodb/db', array(
 $router->add('/mongodb/db', array(
     'controller' => 'mongobench',
     'controller' => 'mongobench',
     'action' => 'db',
     'action' => 'db',
 ));
 ));
 
 
+$router->add('/mongodb/queries', array(
+    'controller' => 'mongobench',
+    'action' => 'queries',
+));
+
 $router->add('/mongodb/fortunes', array(
 $router->add('/mongodb/fortunes', array(
     'controller' => 'mongobench',
     'controller' => 'mongobench',
     'action' => 'fortunes',
     'action' => 'fortunes',

+ 6 - 6
php-phalcon/app/controllers/BenchController.php

@@ -20,6 +20,11 @@ class BenchController extends \Phalcon\Mvc\Controller
     }
     }
 
 
     public function dbAction()
     public function dbAction()
+    {
+        return $this->sendContentAsJson($this->getRandomWorld());
+    }
+
+    public function queriesAction()
     {
     {
 
 
 	$queries = min(500, max(1, $this->filter->sanitize($this->request->getQuery('queries', null, 1), "int")));
 	$queries = min(500, max(1, $this->filter->sanitize($this->request->getQuery('queries', null, 1), "int")));
@@ -30,12 +35,7 @@ class BenchController extends \Phalcon\Mvc\Controller
             $worlds[] = $this->getRandomWorld();
             $worlds[] = $this->getRandomWorld();
         }
         }
 
 
-        if (count($worlds) == 1) {
-            return $this->sendContentAsJson($worlds[0]);
-        }
-        else {
-            return $this->sendContentAsJson($worlds);
-        }
+        return $this->sendContentAsJson($worlds);
     }
     }
 
 
     public function fortunesAction()
     public function fortunesAction()

+ 2 - 2
php-phalcon/benchmark_config

@@ -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=",
       "fortune_url": "/fortunes",
       "fortune_url": "/fortunes",
       "update_url": "/update?queries=",
       "update_url": "/update?queries=",
       "port": 8080,
       "port": 8080,
@@ -26,7 +26,7 @@
     "mongodb": {
     "mongodb": {
       "setup_file": "setup",
       "setup_file": "setup",
       "db_url": "/mongodb/db",
       "db_url": "/mongodb/db",
-      "query_url": "/mongodb/db?queries=",
+      "query_url": "/mongodb/queries?queries=",
       "fortune_url": "/mongodb/fortunes",
       "fortune_url": "/mongodb/fortunes",
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",