Browse Source

Update Eloquent ORM to return objects (#4648)

* Update php-eloquent ORM to return objects
before was returning array

* Change Hamlet orm to raw
And delete old config

* Change laravel-query-builder orm to micro
Joan Miquel 6 years ago
parent
commit
a9f52c3293

+ 0 - 120
frameworks/PHP/hamlet/benchmark_config.fix.json

@@ -1,120 +0,0 @@
-{
-  "framework": "hamlet",
-  "tests": [{
-    "default": {
-      "plaintext_url": "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "mysql",
-      "framework": "hamlet",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "micro",
-      "platform": "None",
-      "webserver": "nginx",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "hamlet",
-      "notes": "",
-      "versus": "php"
-    },
-    "swoole": {
-      "plaintext_url": "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "mysql",
-      "framework": "hamlet",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "micro",
-      "platform": "None",
-      "webserver": "swoole",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "hamlet-swoole",
-      "notes": "",
-      "versus": "php"
-    },
-    "react": {
-      "plaintext_url": "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "mysql",
-      "framework": "hamlet",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "micro",
-      "platform": "None",
-      "webserver": "react",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "hamlet-react",
-      "notes": "",
-      "versus": "php"
-    },
-    "roadrunner": {
-      "plaintext_url": "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "mysql",
-      "framework": "hamlet",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "micro",
-      "platform": "None",
-      "webserver": "roadrunner",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "hamlet-roadrunner",
-      "notes": "",
-      "versus": "php"
-    },
-    "amp": {
-      "plaintext_url": "/plaintext",
-      "json_url": "/json",
-      "db_url": "/db",
-      "query_url": "/queries?queries=",
-      "fortune_url": "/fortunes",
-      "update_url": "/update?queries=",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "mysql",
-      "framework": "hamlet",
-      "language": "PHP",
-      "flavor": "PHP7",
-      "orm": "micro",
-      "platform": "None",
-      "webserver": "amp",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "hamlet-amp",
-      "notes": "",
-      "versus": "php"
-    }
-  }]
-}

+ 3 - 3
frameworks/PHP/hamlet/benchmark_config.json

@@ -15,7 +15,7 @@
       "framework": "hamlet",
       "language": "PHP",
       "flavor": "PHP7",
-      "orm": "micro",
+      "orm": "Raw",
       "platform": "None",
       "webserver": "nginx",
       "os": "Linux",
@@ -38,7 +38,7 @@
       "framework": "hamlet",
       "language": "PHP",
       "flavor": "PHP7",
-      "orm": "micro",
+      "orm": "Raw",
       "platform": "None",
       "webserver": "swoole",
       "os": "Linux",
@@ -61,7 +61,7 @@
       "framework": "hamlet",
       "language": "PHP",
       "flavor": "PHP7",
-      "orm": "micro",
+      "orm": "Raw",
       "platform": "None",
       "webserver": "react",
       "os": "Linux",

+ 1 - 1
frameworks/PHP/php/benchmark_config.json

@@ -248,7 +248,7 @@
       "framework": "None",
       "language": "PHP",
       "flavor": "PHP7",
-      "orm": "Full",
+      "orm": "Micro",
       "platform": "None",
       "webserver": "nginx",
       "os": "Linux",

+ 2 - 2
frameworks/PHP/php/eloquent/db-eloquent.php

@@ -5,7 +5,7 @@ header('Content-type: application/json');
 require __DIR__.'/boot-eloquent.php';
 
 if (! isset($_GET['queries'])) {
-    echo json_encode(World::find(mt_rand(1, 10000))->toArray());
+    echo json_encode(World::find(mt_rand(1, 10000)));
     return;
 }
 
@@ -19,7 +19,7 @@ $arr = [];
 // For each query, store the result set values in the response array
 while (0 < $query_count--) {
     // Store result in array.
-    $arr[] = World::find(mt_rand(1, 10000))->toArray();
+    $arr[] = World::find(mt_rand(1, 10000));
 }
 
 // Use the PHP standard JSON encoder.

+ 9 - 5
frameworks/PHP/php/eloquent/fortune-eloquent.php

@@ -12,13 +12,17 @@ class Fortune extends \Illuminate\Database\Eloquent\Model {
 }
 
 // Define query and store result in array.
-$arr = Fortune::all()->pluck('message', 'id')->all();
+$rows = Fortune::all();
 
-$arr[0] = 'Additional fortune added at request time.';
+$insert = new Fortune();
+$insert->id = 0;
+$insert->message = "Additional fortune added at request time.";
+
+$rows->add($insert);
+$rows = $rows->sortBy("message");
 
-asort($arr);
 ?>
 <!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>
-<?php foreach ( $arr as $id => $fortune ) : ?>
-<tr><td><?= $id ?></td><td><?= htmlspecialchars($fortune, ENT_QUOTES, 'UTF-8') ?></td></tr>
+<?php foreach ( $rows as $fortune ) : ?>
+<tr><td><?= $fortune->id ?></td><td><?= htmlspecialchars($fortune->message, ENT_QUOTES, 'UTF-8') ?></td></tr>
 <?php endforeach ?></table></body></html>