Sfoglia il codice sorgente

Merge pull request #751 from nanocom/patch-2

Comply to spec on queries number for test type 3
Mike Smith 11 anni fa
parent
commit
f97a35281b

+ 2 - 0
php-symfony2-stripped/src/Skamander/BenchmarkBundle/Controller/BenchController.php

@@ -19,6 +19,8 @@ class BenchController extends Controller
     public function dbAction(Request $request)
     {
         $queries = $request->query->getInt('queries', 1);
+        $queries = max(1, $queries);
+        $queries = min(500, $queries);
 
         // possibility for enhancement is the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
         $worlds = array();

+ 4 - 2
php-symfony2/src/Skamander/BenchmarkBundle/Controller/BenchController.php

@@ -19,17 +19,19 @@ class BenchController extends Controller
     public function dbAction(Request $request)
     {
         $queries = $request->query->getInt('queries', 1);
+        $queries = max(1, $queries);
+        $queries = min(500, $queries);
 
         // possibility for enhancement is the use of SplFixedArray -> http://php.net/manual/de/class.splfixedarray.php
         $worlds = array();
         $repo = $this->getDoctrine()
             ->getRepository('SkamanderBenchmarkBundle:World');
 
-        for($i = 0; $i < $queries; ++$i) {
+        for ($i = 0; $i < $queries; ++$i) {
             $worlds[] =  $repo->find(mt_rand(1, 10000));
         }
 
-        if ($queries == 1) {
+        if ($queries == 1 && !$request->query->has('queries')) {
             $worlds = $worlds[0];
         }