Pārlūkot izejas kodu

peachpie updated, simplified (#5269)

- aspnetcore 3.0
- peachpie 1.0.0-appv3073
- tests simplified
Jakub Míšek 5 gadi atpakaļ
vecāks
revīzija
8ff61662f8

+ 8 - 0
frameworks/PHP/peachpie/NuGet.Config

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+  <packageSources>
+    <add key="appveyor" value="https://ci.appveyor.com/nuget/peachpie" />
+  </packageSources>
+
+</configuration>

+ 6 - 8
frameworks/PHP/peachpie/Server/Program.cs

@@ -2,26 +2,24 @@ using System;
 using System.Threading;
 using System.Threading;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using Peachpie.AspNetCore.Web;
+using Microsoft.Extensions.Hosting;
 
 
-namespace MyWebsite.Server
+namespace PeachpieBenchmarks.Server
 {
 {
     class Program
     class Program
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
-            ThreadPool.GetMinThreads(out int workerThread, out int completionThread);
             // Double ThreadPool for non-async calls
             // Double ThreadPool for non-async calls
+            ThreadPool.GetMinThreads(out int workerThread, out int completionThread);
             ThreadPool.SetMinThreads(workerThread * 2, completionThread);
             ThreadPool.SetMinThreads(workerThread * 2, completionThread);
 
 
-            var host = new WebHostBuilder()
+            new WebHostBuilder()
                 .UseKestrel()
                 .UseKestrel()
                 .UseUrls("http://*:8080/")
                 .UseUrls("http://*:8080/")
                 .UseStartup<Startup>()
                 .UseStartup<Startup>()
-                .Build();
-
-            host.Run();
+                .Build()
+                .Run();
         }
         }
     }
     }
 	
 	

+ 2 - 8
frameworks/PHP/peachpie/Server/Server.csproj

@@ -1,18 +1,12 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
 
   <PropertyGroup>
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
     <OutputType>Exe</OutputType>
     <OutputType>Exe</OutputType>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
-    <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.2.0" />
-    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
-    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
-    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.2.1" />
-    <PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
-    <PackageReference Include="Peachpie.AspNetCore.Web" Version="0.9.42" />
+    <PackageReference Include="Peachpie.AspNetCore.Web" Version="1.0.0-appv3073" />
   </ItemGroup>
   </ItemGroup>
 
 
   <ItemGroup>
   <ItemGroup>

+ 1 - 2
frameworks/PHP/peachpie/Website/Website.msbuildproj

@@ -1,9 +1,8 @@
-<Project Sdk="Peachpie.NET.Sdk/0.9.42">
+<Project Sdk="Peachpie.NET.Sdk/1.0.0-appv3073">
 
 
   <PropertyGroup>
   <PropertyGroup>
     <OutputType>Library</OutputType>
     <OutputType>Library</OutputType>
     <TargetFramework>netstandard2.0</TargetFramework>
     <TargetFramework>netstandard2.0</TargetFramework>
-	<AssemblyName>Website</AssemblyName>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>

+ 0 - 1
frameworks/PHP/peachpie/Website/dbraw.php

@@ -52,4 +52,3 @@ function dbraw() {
 }
 }
 
 
 dbraw();
 dbraw();
-?>

+ 14 - 27
frameworks/PHP/peachpie/Website/fortune.php

@@ -1,4 +1,12 @@
-<?php
+<!DOCTYPE html>
+<html><head><title>Fortunes</title></head>
+<body>
+  <table>
+  <tr><th>id</th><th>message</th></tr>
+<?php table(); ?>
+  </table>
+</body>
+</html><?php
 //
 //
 // Database Test
 // Database Test
 //
 //
@@ -23,29 +31,8 @@ function fortune() {
   return $arr;
   return $arr;
 }
 }
 
 
-// Set content type
-header("Content-type: text/html; charset=utf-8");
-
-?>
-<!DOCTYPE html>
-<html>
-<head>
-<title>Fortunes</title>
-</head>
-<body>
-<table>
-<tr>
-<th>id</th>
-<th>message</th>
-</tr>
-<?php
-foreach ( fortune() as $id => $fortune ) {
-?>
-<tr>
-<td><?php echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8'); ?></td>  
-<td><?php echo htmlspecialchars($fortune, ENT_QUOTES, 'UTF-8'); ?></td>
-</tr>
-<?php } ?>
-</table>
-</body>
-</html>
+function table() {
+  foreach ( fortune() as $id => $fortune ) : ?>
+<tr><td><?= $id ?></td><td><?= htmlspecialchars($fortune, ENT_QUOTES, 'UTF-8') ?></td></tr>
+<?php endforeach;
+}

+ 3 - 0
frameworks/PHP/peachpie/Website/info.php

@@ -0,0 +1,3 @@
+<?php
+
+phpinfo();

+ 5 - 24
frameworks/PHP/peachpie/Website/json.php

@@ -1,26 +1,7 @@
 <?php
 <?php
-//
-// JSON Encoding Test
-//
+// Set content type
+header('Content-Type: application/json');
 
 
-function json() {
-  // Set content type
-  header("Content-type: application/json");
-
-  // Create an array with the response string.
-  $arr = array(
-      "message" => "Hello, World!"
-  );
-
-  // Use the PHP standard JSON encoder.
-  // http://www.php.net/manual/en/function.json-encode.php
-  $output =  json_encode($arr);
-
-  // Set content length
-  header("Content-Length: {strlen($output)}");
-
-  echo $output;
-}
-
-json();
-?>
+// Use the PHP standard JSON encoder.
+// http://www.php.net/manual/en/function.json-encode.php
+echo json_encode(['message' => 'Hello, World!']);

+ 2 - 7
frameworks/PHP/peachpie/Website/plaintext.php

@@ -1,12 +1,7 @@
 <?php
 <?php
-//
 // Plaintext Test
 // Plaintext Test
-//
 
 
 // Set content type
 // Set content type
-header("Content-type: text/plain");
-// Set content length
-header("Content-Length: 13");
+header('Content-Type: text/plain');
 
 
-?>
-Hello, World!
+echo 'Hello, World!';

+ 17 - 30
frameworks/PHP/peachpie/Website/updateraw.php

@@ -3,55 +3,42 @@
 // Database Test
 // Database Test
 //
 //
 
 
-function updateraw() {
-  // Database connection (TODO: When it works, use PDO instead)
+// Set content type
+header("Content-type: application/json");
+
+function updateraw(int $query_count) {
+  // Database connection // TODO: use PDO instead
   $link = mysql_pconnect('tfb-database', 'benchmarkdbuser', 'benchmarkdbpass');
   $link = mysql_pconnect('tfb-database', 'benchmarkdbuser', 'benchmarkdbpass');
   mysql_select_db('hello_world', $link);
   mysql_select_db('hello_world', $link);
 
 
-  // Read number of queries to run from URL parameter
-  $query_count = 1;
-  if (isset($_GET['queries'])) {
-    $query_count = (int)$_GET['queries'];
-    if ($query_count > 500) {
-      $query_count = 500;
-    } else if ($query_count < 1) {
-      $query_count = 1;
-    }
-  }
-
   // Create an array with the response string.
   // Create an array with the response string.
-  $arr = array();
-  $id = mt_rand(1, 10000);
-  $randomNumber = mt_rand(1, 1000);
-
+  $arr = [];
+  
+  // Ensure the number of queries to run from URL parameter
+  $query_count = max(min($query_count, 500), 1);
+  
   // For each query, store the result set values in the response array
   // For each query, store the result set values in the response array
   while ($query_count--) {
   while ($query_count--) {
+
+    $id = mt_rand(1, 10000);
+    $randomNumber = mt_rand(1, 10000);
+
     $result = mysql_query("SELECT randomNumber FROM World WHERE id = $id", $link);
     $result = mysql_query("SELECT randomNumber FROM World WHERE id = $id", $link);
     
     
     // Store result in array.
     // Store result in array.
-    $world = array('id' => $id, 'randomNumber' => mysql_result($result, 0));
+    $world = ['id' => $id, 'randomNumber' => mysql_result($result, 0)];
     $world['randomNumber'] = $randomNumber;
     $world['randomNumber'] = $randomNumber;
 
 
     mysql_query("UPDATE World SET randomNumber = $randomNumber WHERE id = $id", $link);
     mysql_query("UPDATE World SET randomNumber = $randomNumber WHERE id = $id", $link);
     
     
     $arr[] = $world;
     $arr[] = $world;
-    $id = mt_rand(1, 10000);
-    $randomNumber = mt_rand(1, 10000);
   }
   }
 
 
   mysql_close($link);
   mysql_close($link);
 
 
-  // Set content type
-  header("Content-type: application/json");
-
   // Use the PHP standard JSON encoder.
   // Use the PHP standard JSON encoder.
   // http://www.php.net/manual/en/function.json-encode.php
   // http://www.php.net/manual/en/function.json-encode.php
-  $output = json_encode($arr);
-  // Set content length
-  header("Content-Length: {strlen($output)}");
-
-  echo $output;
+  echo json_encode($arr);
 }
 }
 
 
-updateraw();
-?>
+updateraw((int)$_GET['queries']);

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

@@ -20,7 +20,7 @@
       "webserver": "Kestrel",
       "webserver": "Kestrel",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
-      "display_name": "Peachpie",
+      "display_name": "peachpie",
       "notes": "",
       "notes": "",
       "versus": "php"
       "versus": "php"
     }
     }

+ 4 - 4
frameworks/PHP/peachpie/peachpie.dockerfile

@@ -1,11 +1,11 @@
-FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
+FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
 WORKDIR /app
 WORKDIR /app
 COPY . .
 COPY . .
-RUN dotnet publish -c Release -o ../out Server
+RUN dotnet publish -c Release -o out Server
 
 
-FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
+FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime
 ENV COMPlus_ReadyToRun 0
 ENV COMPlus_ReadyToRun 0
 WORKDIR /app
 WORKDIR /app
 COPY --from=build /app/out ./
 COPY --from=build /app/out ./
 
 
-ENTRYPOINT ["dotnet", "Server.dll"]
+ENTRYPOINT ["dotnet", "Server.dll", "--urls=http://*:8080"]