|
@@ -5,6 +5,7 @@ namespace FrameworkBenchmarks\Controller;
|
|
use Zend\Mvc\Controller\AbstractActionController;
|
|
use Zend\Mvc\Controller\AbstractActionController;
|
|
use Zend\Stdlib\ArrayUtils;
|
|
use Zend\Stdlib\ArrayUtils;
|
|
use Zend\View\Model\JsonModel;
|
|
use Zend\View\Model\JsonModel;
|
|
|
|
+use Zend\Http\Headers;
|
|
use Zend\Db\TableGateway\TableGateway;
|
|
use Zend\Db\TableGateway\TableGateway;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -13,7 +14,7 @@ use Zend\Db\TableGateway\TableGateway;
|
|
* @author Marco Pivetta <[email protected]>
|
|
* @author Marco Pivetta <[email protected]>
|
|
* @link http://www.techempower.com/benchmarks
|
|
* @link http://www.techempower.com/benchmarks
|
|
*/
|
|
*/
|
|
-class DbController extends AbstractActionController
|
|
|
|
|
|
+class BenchController extends AbstractActionController
|
|
{
|
|
{
|
|
/**
|
|
/**
|
|
* @var \Zend\Db\TableGateway\TableGateway
|
|
* @var \Zend\Db\TableGateway\TableGateway
|
|
@@ -28,6 +29,16 @@ class DbController extends AbstractActionController
|
|
$this->tableGateway = $tableGateway;
|
|
$this->tableGateway = $tableGateway;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function indexAction()
|
|
|
|
+ {
|
|
|
|
+ return array('message' => 'test123');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function jsonAction()
|
|
|
|
+ {
|
|
|
|
+ return new JsonModel(array('message' => 'Hello, World!'));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return \Zend\View\Model\JsonModel
|
|
* @return \Zend\View\Model\JsonModel
|
|
*/
|
|
*/
|
|
@@ -63,4 +74,36 @@ class DbController extends AbstractActionController
|
|
|
|
|
|
return new JsonModel($worlds);
|
|
return new JsonModel($worlds);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function updateAction()
|
|
|
|
+ {
|
|
|
|
+ $request = $this->getRequest();
|
|
|
|
+ $queries = (int) $request->getQuery('queries', 1);
|
|
|
|
+ $queries = max(1, $queries);
|
|
|
|
+ $queries = min(500, $queries);
|
|
|
|
+
|
|
|
|
+ $worlds = array();
|
|
|
|
+
|
|
|
|
+ for ($i = 0; $i < $queries; $i += 1) {
|
|
|
|
+ $id = mt_rand(1, 10000);
|
|
|
|
+ foreach ($this->tableGateway->select(array('id' => $id)) as $found) {
|
|
|
|
+ $random_number = mt_rand(1, 10000);
|
|
|
|
+ $found->randomNumber = $random_number;
|
|
|
|
+ $this->tableGateway->update(array('randomNumber' => $random_number), array('id' => $id));
|
|
|
|
+ $worlds[] = $found;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new JsonModel($worlds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function plaintextAction()
|
|
|
|
+ {
|
|
|
|
+ $response = $this->getResponse();
|
|
|
|
+ $response->getHeaders()->addHeaders(array('COntent-Type' => 'text/plain'));
|
|
|
|
+ $response->setContent('Hello, World!');
|
|
|
|
+ return $response;
|
|
|
|
+ // echo "Hello, World!";
|
|
|
|
+ // return;
|
|
|
|
+ }
|
|
}
|
|
}
|