瀏覽代碼

php/peachpie updated and fixed broken compilation (#5746)

Jakub Míšek 5 年之前
父節點
當前提交
81d74625a6

+ 26 - 24
frameworks/PHP/peachpie/Benchmarks.sln

@@ -1,11 +1,10 @@
-
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30114.105
 MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Website", "Website\Website.msbuildproj", "{A271793F-72BF-429D-9EC8-83C03559CBD6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Website", "Website\Website.msbuildproj", "{A271793F-72BF-429D-9EC8-83C03559CBD6}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{AF5D53C1-32B5-473F-9229-817608068701}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{AF5D53C1-32B5-473F-9229-817608068701}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,33 +15,36 @@ Global
 		Release|x64 = Release|x64
 		Release|x86 = Release|x86
 	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.ActiveCfg = Debug|x64
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.Build.0 = Debug|x64
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.ActiveCfg = Debug|x86
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.Build.0 = Debug|x86
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.Build.0 = Debug|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.Build.0 = Debug|Any CPU
 		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|Any CPU.Build.0 = Release|Any CPU
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.ActiveCfg = Release|x64
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.Build.0 = Release|x64
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.ActiveCfg = Release|x86
-		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.Build.0 = Release|x86
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.ActiveCfg = Release|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.Build.0 = Release|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.ActiveCfg = Release|Any CPU
+		{A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.Build.0 = Release|Any CPU
 		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.ActiveCfg = Debug|x64
-		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.Build.0 = Debug|x64
-		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.ActiveCfg = Debug|x86
-		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.Build.0 = Debug|x86
+		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.Build.0 = Debug|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.Build.0 = Debug|Any CPU
 		{AF5D53C1-32B5-473F-9229-817608068701}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{AF5D53C1-32B5-473F-9229-817608068701}.Release|Any CPU.Build.0 = Release|Any CPU
-		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.ActiveCfg = Release|x64
-		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.Build.0 = Release|x64
-		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.ActiveCfg = Release|x86
-		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.Build.0 = Release|x86
+		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.ActiveCfg = Release|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.Build.0 = Release|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.ActiveCfg = Release|Any CPU
+		{AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {B594A287-1B0F-4DDC-A815-2CF24C23E9DC}
 	EndGlobalSection
 EndGlobal

+ 30 - 1
frameworks/PHP/peachpie/Server/Program.cs

@@ -2,6 +2,9 @@ using System;
 using System.Threading;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http.Features;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 
 namespace PeachpieBenchmarks.Server
@@ -14,8 +17,15 @@ namespace PeachpieBenchmarks.Server
             ThreadPool.GetMinThreads(out int workerThread, out int completionThread);
             ThreadPool.SetMinThreads(workerThread * 2, completionThread);
 
+            // https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview
+
             new WebHostBuilder()
-                .UseKestrel()
+                .UseKestrel(options =>
+                {
+                    options.AddServerHeader = true; // tfb requires "Server" header
+                    //options.Limits.KeepAliveTimeout = Timeout.InfiniteTimeSpan; // default 2:00
+                    //options.Limits.MaxConcurrentConnections = 1000;
+                })
                 .UseUrls("http://*:8080/")
                 .UseStartup<Startup>()
                 .Build()
@@ -25,8 +35,27 @@ namespace PeachpieBenchmarks.Server
 	
 	class Startup
     {
+        public void ConfigureServices(IServiceCollection services)
+        {
+            // disable timeout
+            services.AddPhp(options =>
+            {
+                options.Core.ExecutionTimeout = -1;
+            });
+        }
+
         public void Configure(IApplicationBuilder app)
         {
+            //// disable response buffering and chunked transfer
+            //app.Use((httpcontext, next) =>
+            //{
+            //    var responsefeature = httpcontext.Features.Get<IHttpResponseBodyFeature>();
+            //    responsefeature?.DisableBuffering();
+
+            //    //
+            //    return next();
+            //});
+
             // app.UseResponseBuffering();
             app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "Website"));
             // app.UseDefaultFiles();

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

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Library</OutputType>
-    <TargetFramework>netstandard2.0</TargetFramework>
+    <TargetFramework>netstandard2.1</TargetFramework>
   </PropertyGroup>
 
   <ItemGroup>

+ 24 - 0
frameworks/PHP/peachpie/Website/db.php

@@ -0,0 +1,24 @@
+<?php
+//
+// Database Test
+//
+
+function db() {
+  
+  // Set content type
+  header("Content-type: application/json");
+
+  // Database connection (TODO: When it works, use PDO instead)
+  $link = mysql_pconnect('tfb-database', 'benchmarkdbuser', 'benchmarkdbpass');
+  mysql_select_db('hello_world', $link);
+
+  $id = mt_rand(1, 10000);
+  $result = mysql_query("SELECT id,randomNumber FROM World WHERE id=$id", $link);
+
+  // Store result in array.
+  echo json_encode( mysql_fetch_assoc($result) );
+
+  mysql_close($link);
+}
+
+db();

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

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

+ 37 - 0
frameworks/PHP/peachpie/Website/query.php

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

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

@@ -4,8 +4,8 @@
     "default": {
       "json_url": "/json.php",
       "plaintext_url": "/plaintext.php",
-      "db_url": "/dbraw.php",
-      "query_url": "/dbraw.php?queries=",
+      "db_url": "/db.php",
+      "query_url": "/query.php?queries=",
       "fortune_url": "/fortune.php",
       "update_url": "/updateraw.php?queries=",
       "port": 8080,
@@ -23,7 +23,7 @@
       "display_name": "peachpie",
       "notes": "",
       "versus": "php",
-      "tags": ["broken"]
+      "tags": []
     }
   }]
 }

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

@@ -1,5 +1,5 @@
 {
     "msbuild-sdks": {
-        "Peachpie.NET.Sdk": "0.9.910"
+        "Peachpie.NET.Sdk": "1.0.0-appv3917"
     }
 }