Program.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Threading;
  3. using Microsoft.AspNetCore.Builder;
  4. using Microsoft.AspNetCore.Hosting;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.AspNetCore.Http.Features;
  7. using Microsoft.Extensions.DependencyInjection;
  8. using Microsoft.Extensions.Hosting;
  9. namespace PeachpieBenchmarks.Server
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. // Double ThreadPool for non-async calls
  16. ThreadPool.GetMinThreads(out int workerThread, out int completionThread);
  17. ThreadPool.SetMinThreads(workerThread * 2, completionThread);
  18. // https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview
  19. new WebHostBuilder()
  20. .UseKestrel(options =>
  21. {
  22. options.AddServerHeader = true; // tfb requires "Server" header
  23. //options.Limits.KeepAliveTimeout = Timeout.InfiniteTimeSpan; // default 2:00
  24. //options.Limits.MaxConcurrentConnections = 1000;
  25. })
  26. .UseUrls("http://*:8080/")
  27. .UseStartup<Startup>()
  28. .Build()
  29. .Run();
  30. }
  31. }
  32. class Startup
  33. {
  34. public void ConfigureServices(IServiceCollection services)
  35. {
  36. services.AddPhp(options =>
  37. {
  38. // disable timeout
  39. options.Core.ExecutionTimeout = 0;
  40. });
  41. }
  42. public void Configure(IApplicationBuilder app)
  43. {
  44. //// disable response buffering and chunked transfer
  45. //app.Use((httpcontext, next) =>
  46. //{
  47. // var responsefeature = httpcontext.Features.Get<IHttpResponseBodyFeature>();
  48. // responsefeature?.DisableBuffering();
  49. // //
  50. // return next();
  51. //});
  52. // app.UseResponseBuffering();
  53. app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "Website"));
  54. // app.UseDefaultFiles();
  55. // app.UseStaticFiles();
  56. }
  57. }
  58. }