Skip to content

Commit d2f9afc

Browse files
committed
Create Test TechEmpower#4 Fortunes.
1 parent 5a7dd28 commit d2f9afc

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

frameworks/PHP/slim/benchmark_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"query_url": "/queries?queries=",
99
"plaintext_url": "/plaintext",
1010
"update_url": "/updates?queries",
11+
"fortune_url": "/fortunes",
1112
"port": 8080,
1213
"approach": "Realistic",
1314
"classification": "Micro",

frameworks/PHP/slim/index.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@
6060
}
6161
);
6262

63+
// Test 4: Fortunes
64+
$app->get('/fortunes', function ($request, $response) {
65+
$sth = $this->db->query('SELECT * FROM fortune');
66+
67+
$arr = $sth->fetch(PDO::FETCH_KEY_PAIR);
68+
$arr[0] = 'Additional fortune added at request time.';
69+
asort($arr);
70+
71+
ob_start();
72+
include __DIR__.'/index.tpl.phtml';
73+
$html = ob_get_contents();
74+
ob_end_clean();
75+
76+
$body = $response->getBody();
77+
$body->write($html);
78+
79+
return $response
80+
->withBody($body)
81+
->withHeader('Content-Type', 'text/html');
82+
}
83+
);
84+
6385
// Test 5: Database updates
6486
$app->get('/updates', function ($request, $response) {
6587
$sth = $this->db->prepare('SELECT * FROM world WHERE id = ?');

frameworks/PHP/slim/index.tpl.phtml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head><title>Fortunes</title></head>
4+
<body>
5+
<table>
6+
<tr><th>id</th><th>message</th></tr>
7+
<?php foreach ($arr as $id => $message): ?>
8+
<tr><td><?=$id?></td><td><?=$message?></td></tr>
9+
<?php endforeach; ?>
10+
</table>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)