Browse Source

Merge branch 'master' of github.com:TechEmpower/FrameworkBenchmarks

Michael Hixson 12 years ago
parent
commit
52450f650f

+ 2 - 2
cake/app/Config/database.php

@@ -67,7 +67,7 @@ class DATABASE_CONFIG {
 		'password' => 'benchmarkdbpass',
 		'database' => 'hello_world',
 		'prefix' => '',
-		//'encoding' => 'utf8',
+		'encoding' => 'utf8',
 	);
 
 	public $test = array(
@@ -78,6 +78,6 @@ class DATABASE_CONFIG {
 		'password' => 'benchmarkdbpass',
 		'database' => 'hello_world',
 		'prefix' => '',
-		//'encoding' => 'utf8',
+		'encoding' => 'utf8',
 	);
 }

+ 31 - 0
cake/app/Controller/FortunesController.php

@@ -0,0 +1,31 @@
+<?php
+
+App::uses('AppController', 'Controller');
+
+class FortunesController extends AppController {
+
+	public function index() {
+		// use full view stack as encouraged by test rules
+		$this->layout = 'benchmark';
+		$this->set('title_for_layout', 'Fortunes');
+
+		// using prepared query as encouraged by test rules
+		$db      = $this->Fortune->getDataSource();
+		$results = $db->fetchAll('SELECT * FROM Fortune');
+
+		// stuffing in the dynamic data
+		$results[]['Fortune'] = [
+			'id'      => 0,
+			'message' => 'Additional fortune added at request time.'
+		];
+
+		// because we are performance concerned we don't use Hash::sort()
+		foreach ($results as $result) {
+			$fortunes[$result['Fortune']['id']] = $result['Fortune']['message'];
+		}
+		asort($fortunes);
+
+		$this->set('fortunes', $fortunes);
+	}
+
+}

+ 24 - 0
cake/app/Controller/PlaintextController.php

@@ -0,0 +1,24 @@
+<?php
+
+App::uses('AppController', 'Controller');
+
+class PlaintextController extends AppController {
+
+	public function index() {
+		$this->autoRender = false;
+		header("Content-type: text/plain");
+		echo 'Hello, World!';
+
+		/*
+		 * Because this test is focused on routing we don't involve the view.
+		 *
+		 * Normally we would create a template file index.ctp containing "Hello, World!"
+		 * in app/View/Plaintext and:
+		 *
+
+		$this->autoLayout = false;
+		$this->response->type('text');
+
+		 */
+	}
+}

+ 6 - 0
cake/app/Model/Fortune.php

@@ -0,0 +1,6 @@
+<?php
+
+class Fortune extends AppModel {
+	public $useTable = 'Fortune'; // This model uses a database table 'Fortune'
+}
+

+ 14 - 0
cake/app/View/Fortunes/index.ctp

@@ -0,0 +1,14 @@
+<table>
+	<tr>
+		<th>id</th>
+		<th>message</th>
+	</tr>
+	<?php
+	foreach ($fortunes as $key => $fortune) {
+		?>
+		<tr>
+			<td><?php echo $key; ?></td>
+			<td><?php echo h($fortune); ?></td>
+		</tr>
+	<?php } ?>
+</table>

+ 11 - 0
cake/app/View/Layouts/benchmark.ctp

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>
+		<?php echo $title_for_layout; ?>
+	</title>
+</head>
+<body>
+	<?php echo $this->fetch('content'); ?>
+</body>
+</html>