Browse Source

Add update test for phalcon

Patrick Falls 12 years ago
parent
commit
b504cff321
2 changed files with 22 additions and 0 deletions
  1. 21 0
      php-phalcon/app/controllers/BenchController.php
  2. 1 0
      php-phalcon/benchmark_config

+ 21 - 0
php-phalcon/app/controllers/BenchController.php

@@ -60,6 +60,27 @@ class BenchController extends \Phalcon\Mvc\Controller
         $this->view->fortunes = $fortunes;
     }
 
+    public function updateAction() {
+
+        $queries = $this->request->getQuery('queries', null, 1);
+        if($queries < 1) {
+            $queries = 1;
+        } else if ($queries > 500) {
+            $queries = 500;
+        }
+
+        $worlds = array();
+
+        for ($i = 0; $i < $queries; ++$i) {
+            $world = Worlds::findFirst(mt_rand(1, 10000));
+            $world->randomNumber = mt_rand(1, 10000);
+            $world->save();
+            $worlds[] = $world
+        }
+
+        return $this->sendContentAsJson($worlds);
+    }
+
     private function sendContentAsJson($content) {
         $response = new Phalcon\Http\Response(json_encode($content));
         $response->setHeader("Content-Type", "application/json");

+ 1 - 0
php-phalcon/benchmark_config

@@ -7,6 +7,7 @@
       "db_url": "/db",
       "query_url": "/db?queries=",
       "fortune_url": "/fortunes",
+      "update_url": "/update?queries=",
       "port": 8080,
       "sort": 72
     }