Browse Source

Use .NET Core 2.0.0-preview1 (#2855)

* Use .NET Core 2.0.0-preview1
- move from dotnet-dev-1.0.0-preview2.1-003177 to dotnet-dev-2.0.0-preview1
- convert .NET Core Benchmarks project from project.json to .csproj
  - use latest available versions of all dependencies
- catch up with latest code in Microsoft ASP.NET fork
  - do not grab scoped services when constructing singletons; primarily affects DbContexts
  - compile EF queries
  - WebListener -> HttpSys
  - enable specific requested scenarios e.g. don't support /mvc/plaintext when plaintext requested
  - remove hack and use `response.ContentLength` property; hack no longer a significant optimization
  - remove use of old PlatformAbstractions package
- publish as part of test scenarios and enable MVC Razor Precompilation
- change `DebugInfoPageMiddleware` to return 404 status code
  - prevent apparent success when "benchmarking" incorrect URLs
- add appsettings.json file for Windows runs; use LocalDb by default on Windows

Improve database scenario performance (beyond compiling EF queries)
- enforce Max Auto Prepare for PostgreSQL EF/Dapper
  - merge from https://github.com/roji/FrameworkBenchmarks.git dougbu/update.net.core-autoprepare
  - thanks @roji!
  - The "Max Auto Prepare" connection string parameter is important for PostgreSQL performance when running
    EF/Dapper benchmarks. Added this parameter in appsetings.postgresql.json and a check for its existence
    on benchmark startup.
- `Prepare()` the update command in `RawDb.LoadMultipleUpdatesRows()`
  - may improve performance with Postgres even though the command is executed just once
- remove `NoTransactionSqlServerConnection` hack; leave auto transactions enabled

nits:
- remove unused tool dependencies
- display where `WebHostBuilder` is found during startup; confirms use of publish folder
- slightly improve Windows scripts
- add appsettings.postgresql.json to csproj
- remove obsolete launchSettings.json
- add and correct links in README.md
- remove duplicate property setting from benchmark_config.json
- clean up whitespace
- more `var`

- simplify `services.AddDbContextPool<TContext>()` delegate

* Fix typo the new `Prepare()` uncovered

* Remove `Max Auto Prepare` connection string parameter
- basically reverts aspnet/FrameworkBenchmarks#4
- removing parameter allows Dapper to use the Postgres database after large update e.g. /updates/dapper?queries=501
  - may not be the root cause; should be able to prepare these statements
Doug Bunting 8 years ago
parent
commit
70a2dac663
52 changed files with 350 additions and 435 deletions
  1. 29 0
      frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj
  2. 22 0
      frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.sln
  3. 0 19
      frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.xproj
  4. 3 3
      frameworks/CSharp/aspnetcore/Benchmarks/Configuration/AppSettings.cs
  5. 7 7
      frameworks/CSharp/aspnetcore/Benchmarks/Configuration/Scenarios.cs
  6. 1 1
      frameworks/CSharp/aspnetcore/Benchmarks/Controllers/FortunesController.cs
  7. 7 61
      frameworks/CSharp/aspnetcore/Benchmarks/Data/ApplicationDbContext.cs
  8. 46 38
      frameworks/CSharp/aspnetcore/Benchmarks/Data/ApplicationDbSeeder.cs
  9. 3 3
      frameworks/CSharp/aspnetcore/Benchmarks/Data/DapperDb.cs
  10. 35 14
      frameworks/CSharp/aspnetcore/Benchmarks/Data/EfDb.cs
  11. 0 43
      frameworks/CSharp/aspnetcore/Benchmarks/Data/NoTransactionSqlServerConnection.cs
  12. 8 7
      frameworks/CSharp/aspnetcore/Benchmarks/Data/RawDb.cs
  13. 4 4
      frameworks/CSharp/aspnetcore/Benchmarks/Data/World.cs
  14. 7 4
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/DebugInfoPageMiddleware.cs
  15. 7 7
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesDapperMiddleware.cs
  16. 3 3
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesEfMiddleware.cs
  17. 7 7
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesRawMiddleware.cs
  18. 5 6
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/JsonMiddleware.cs
  19. 7 6
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesDapperMiddleware.cs
  20. 4 3
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesEfMiddleware.cs
  21. 7 6
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesRawMiddleware.cs
  22. 8 7
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesDapperMiddleware.cs
  23. 4 3
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesEfMiddleware.cs
  24. 8 7
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesRawMiddleware.cs
  25. 14 10
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/PlaintextMiddleware.cs
  26. 6 6
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryDapperMiddleware.cs
  27. 2 2
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryEfMiddleware.cs
  28. 6 6
      frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryRawMiddleware.cs
  29. 15 11
      frameworks/CSharp/aspnetcore/Benchmarks/Program.cs
  30. 0 27
      frameworks/CSharp/aspnetcore/Benchmarks/Properties/launchSettings.json
  31. 21 24
      frameworks/CSharp/aspnetcore/Benchmarks/Startup.cs
  32. 3 0
      frameworks/CSharp/aspnetcore/Benchmarks/appsettings.json
  33. 0 59
      frameworks/CSharp/aspnetcore/Benchmarks/project.json
  34. 3 3
      frameworks/CSharp/aspnetcore/README.md
  35. 11 12
      frameworks/CSharp/aspnetcore/benchmark_config.json
  36. 2 2
      frameworks/CSharp/aspnetcore/run-linux.sh
  37. 2 2
      frameworks/CSharp/aspnetcore/run-windows.ps1
  38. 1 1
      frameworks/CSharp/aspnetcore/setup-dapper.sh
  39. 1 1
      frameworks/CSharp/aspnetcore/setup-ef.sh
  40. 3 0
      frameworks/CSharp/aspnetcore/setup-httpsys.sh
  41. 5 0
      frameworks/CSharp/aspnetcore/setup-mvc-dapper.sh
  42. 5 0
      frameworks/CSharp/aspnetcore/setup-mvc-ef.sh
  43. 3 0
      frameworks/CSharp/aspnetcore/setup-mvc-httpsys.sh
  44. 3 0
      frameworks/CSharp/aspnetcore/setup-mvc-json.sh
  45. 3 0
      frameworks/CSharp/aspnetcore/setup-mvc-plaintext.sh
  46. 5 0
      frameworks/CSharp/aspnetcore/setup-mvc-raw.sh
  47. 0 3
      frameworks/CSharp/aspnetcore/setup-mvc-weblistener.sh
  48. 1 1
      frameworks/CSharp/aspnetcore/setup-mvc-windows.sh
  49. 1 1
      frameworks/CSharp/aspnetcore/setup-raw.sh
  50. 0 3
      frameworks/CSharp/aspnetcore/setup-weblistener.sh
  51. 1 1
      frameworks/CSharp/aspnetcore/setup-windows.sh
  52. 1 1
      toolset/setup/linux/languages/dotnetcore.sh

+ 29 - 0
frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj

@@ -0,0 +1,29 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <OutputType>Exe</OutputType>
+    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Update="wwwroot/**" CopyToOutputDirectory="PreserveNewest" />
+    <None Include="appsettings.json" CopyToOutputDirectory="PreserveNewest" />
+    <None Include="appsettings.postgresql.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Dapper" Version="1.50.2" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.Server.HttpSys" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0-preview1-final" />
+    <PackageReference Include="Npgsql" Version="3.2.2" />
+    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0-preview1" />
+  </ItemGroup>
+</Project>

+ 22 - 0
frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26507.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks.csproj", "{8D5521DB-5F71-4F26-9E60-92A158E1F50E}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{8D5521DB-5F71-4F26-9E60-92A158E1F50E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{8D5521DB-5F71-4F26-9E60-92A158E1F50E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{8D5521DB-5F71-4F26-9E60-92A158E1F50E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{8D5521DB-5F71-4F26-9E60-92A158E1F50E}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 0 - 19
frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.xproj

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
-    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>ec62acf4-8b19-41c2-b699-d75cab7763df</ProjectGuid>
-    <RootNamespace>Benchmarks</RootNamespace>
-    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
-    <OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\</OutputPath>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SchemaVersion>2.0</SchemaVersion>
-    <DevelopmentServerPort>13007</DevelopmentServerPort>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project>

+ 3 - 3
frameworks/CSharp/aspnetcore/Benchmarks/Configuration/AppSettings.cs

@@ -1,12 +1,12 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
-
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 namespace Benchmarks.Configuration
 {
     public class AppSettings
     {
         public string ConnectionString { get; set; }
+
         public DatabaseServer Database { get; set; } = DatabaseServer.SqlServer;
     }
 }

+ 7 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Configuration/Scenarios.cs

@@ -1,11 +1,11 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Collections.Generic;
-using System.Reflection;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Reflection;
 using Microsoft.EntityFrameworkCore.Internal;
 
 namespace Benchmarks.Configuration
@@ -134,19 +134,19 @@ namespace Benchmarks.Configuration
                 EnableDefault();
                 return 2;
             }
-            
+
             var props = typeof(Scenarios).GetTypeInfo().DeclaredProperties
-                .Where(p => string.Equals(partialName, "[all]", StringComparison.OrdinalIgnoreCase) || p.Name.IndexOf(partialName, StringComparison.OrdinalIgnoreCase) >= 0)
+                .Where(p => string.Equals(partialName, "[all]", StringComparison.OrdinalIgnoreCase) || p.Name.StartsWith(partialName, StringComparison.OrdinalIgnoreCase))
                 .ToList();
 
             foreach (var p in props)
             {
                 p.SetValue(this, true);
             }
-            
+
             return props.Count;
         }
-        
+
         public void EnableDefault()
         {
             Plaintext = true;

+ 1 - 1
frameworks/CSharp/aspnetcore/Benchmarks/Controllers/FortunesController.cs

@@ -13,7 +13,7 @@ namespace Benchmarks.Controllers
     {
         [HttpGet("raw")]
         public async Task<IActionResult> Raw()
-        {   
+        {
             var db = HttpContext.RequestServices.GetRequiredService<RawDb>();
             return View("Fortunes", await db.LoadFortunesRows());
         }

+ 7 - 61
frameworks/CSharp/aspnetcore/Benchmarks/Data/ApplicationDbContext.cs

@@ -1,75 +1,21 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
-using System.Linq;
-using Benchmarks.Configuration;
 using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.Internal;
-using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
-using Microsoft.Extensions.Options;
-using Microsoft.Extensions.DependencyInjection;
 
 namespace Benchmarks.Data
 {
-    public class ApplicationDbContext : DbContext
+    public sealed class ApplicationDbContext : DbContext
     {
-        private readonly AppSettings _appSettings;
-
-        public ApplicationDbContext(IOptions<AppSettings> appSettings)
+        public ApplicationDbContext(DbContextOptions options)
+            : base(options)
         {
-            _appSettings = appSettings.Value;
+            ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
+            ChangeTracker.AutoDetectChangesEnabled = false;
         }
 
         public DbSet<World> World { get; set; }
 
         public DbSet<Fortune> Fortune { get; set; }
-
-        public bool UseBatchUpdate 
-        { 
-            get
-            {
-                return _appSettings.Database != DatabaseServer.PostgreSql;
-            }
-        } 
-
-        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
-        {
-            if (_appSettings.Database == DatabaseServer.PostgreSql)
-            {
-                optionsBuilder.UseNpgsql(_appSettings.ConnectionString);
-            }
-            else
-            {
-                var extension = GetOrCreateExtension(optionsBuilder);
-                extension.ConnectionString = _appSettings.ConnectionString;
-                ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);
-            }
-        }
-
-        private static SqlServerOptionsExtension GetOrCreateExtension(DbContextOptionsBuilder optionsBuilder)
-        {
-            var existing = optionsBuilder.Options.FindExtension<NoTxSqlServerOptionsExtension>();
-            return existing != null
-                ? new NoTxSqlServerOptionsExtension(existing)
-                : new NoTxSqlServerOptionsExtension();
-        }
-
-        private class NoTxSqlServerOptionsExtension : SqlServerOptionsExtension
-        {
-            public NoTxSqlServerOptionsExtension()
-            {
-            }
-
-            public NoTxSqlServerOptionsExtension(NoTxSqlServerOptionsExtension copyFrom) : base(copyFrom)
-            {
-            }
-            public override void ApplyServices(IServiceCollection services)
-            {
-                base.ApplyServices(services);
-                services.Remove(services.First((sd) => sd.ServiceType == typeof(ISqlServerConnection)));
-                services.AddScoped<ISqlServerConnection, NoTransactionSqlServerConnection>();
-            }
-        }
     }
 }

+ 46 - 38
frameworks/CSharp/aspnetcore/Benchmarks/Data/ApplicationDbSeeder.cs

@@ -1,8 +1,9 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Linq;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Benchmarks.Data
 {
@@ -10,13 +11,13 @@ namespace Benchmarks.Data
     {
         private readonly object _locker = new object();
         private readonly IRandom _random;
-        private readonly ApplicationDbContext _dbContext;
+        private readonly IServiceScopeFactory _serviceScopeFactory;
         private bool _seeded = false;
 
-        public ApplicationDbSeeder(IRandom random, ApplicationDbContext dbContext)
+        public ApplicationDbSeeder(IRandom random, IServiceScopeFactory serviceScopeFactory)
         {
             _random = random;
-            _dbContext = dbContext;
+            _serviceScopeFactory = serviceScopeFactory;
         }
 
         public bool Seed()
@@ -29,51 +30,58 @@ namespace Benchmarks.Data
                     {
                         try
                         {
-                            var world = _dbContext.World.Count();
-                            var fortune = _dbContext.Fortune.Count();
-
-                            if (world == 0 || fortune == 0)
+                            using (var serviceScope = _serviceScopeFactory.CreateScope())
                             {
-                                if (world == 0)
+                                var dbContext = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
+
+                                dbContext.Database.EnsureCreated();
+
+                                var world = dbContext.World.Count();
+                                var fortune = dbContext.Fortune.Count();
+
+                                if (world == 0 || fortune == 0)
                                 {
-                                    for (int i = 0; i < 10000; i++)
+                                    if (world == 0)
                                     {
-                                        _dbContext.World.Add(new World { RandomNumber = _random.Next(1, 10001) });
+                                        for (int i = 0; i < 10000; i++)
+                                        {
+                                            dbContext.World.Add(new World { RandomNumber = _random.Next(1, 10001) });
+                                        }
+                                        dbContext.SaveChanges();
                                     }
-                                    _dbContext.SaveChanges();
-                                }
 
-                                if (fortune == 0)
-                                {
-                                    _dbContext.Fortune.Add(new Fortune { Message = "fortune: No such file or directory" });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "A computer scientist is someone who fixes things that aren't broken." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "After enough decimal places, nobody gives a damn." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1" });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "A computer program does what you tell it to do, not what you want it to do." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen" });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "Any program that runs right is obsolete." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "A list is only as strong as its weakest link. — Donald Knuth" });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "Feature: A bug with seniority." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "Computers make very fast, very accurate mistakes." });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "<script>alert(\"This should not be displayed in a browser alert box.\");</script>" });
-                                    _dbContext.Fortune.Add(new Fortune { Message = "フレームワークのベンチマーク" });
+                                    if (fortune == 0)
+                                    {
+                                        dbContext.Fortune.Add(new Fortune { Message = "fortune: No such file or directory" });
+                                        dbContext.Fortune.Add(new Fortune { Message = "A computer scientist is someone who fixes things that aren't broken." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "After enough decimal places, nobody gives a damn." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1" });
+                                        dbContext.Fortune.Add(new Fortune { Message = "A computer program does what you tell it to do, not what you want it to do." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen" });
+                                        dbContext.Fortune.Add(new Fortune { Message = "Any program that runs right is obsolete." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "A list is only as strong as its weakest link. — Donald Knuth" });
+                                        dbContext.Fortune.Add(new Fortune { Message = "Feature: A bug with seniority." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "Computers make very fast, very accurate mistakes." });
+                                        dbContext.Fortune.Add(new Fortune { Message = "<script>alert(\"This should not be displayed in a browser alert box.\");</script>" });
+                                        dbContext.Fortune.Add(new Fortune { Message = "フレームワークのベンチマーク" });
 
-                                    _dbContext.SaveChanges();
+                                        dbContext.SaveChanges();
+                                    }
+
+                                    Console.WriteLine("Database successfully seeded!");
+                                }
+                                else
+                                {
+                                    Console.WriteLine("Database already seeded!");
                                 }
 
-                                Console.WriteLine("Database successfully seeded!");
+                                _seeded = true;
+                                return true;
                             }
-                            else
-                            {
-                                Console.WriteLine("Database already seeded!");
-                            }
-
-                            _seeded = true;
-                            return true;
                         }
                         catch (Exception ex)
                         {
-                            Console.Error.WriteLine("Error trying to seed the database. Have you run 'dnx ef database update'?");
+                            Console.Error.WriteLine("Error trying to seed the database");
                             Console.Error.WriteLine(ex);
 
                             return false;

+ 3 - 3
frameworks/CSharp/aspnetcore/Benchmarks/Data/DapperDb.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Collections.Generic;
@@ -114,4 +114,4 @@ namespace Benchmarks.Data
             return result;
         }
     }
-}
+}

+ 35 - 14
frameworks/CSharp/aspnetcore/Benchmarks/Data/EfDb.cs

@@ -1,9 +1,14 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
+using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Threading.Tasks;
+using Benchmarks.Configuration;
 using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Query;
+using Microsoft.Extensions.Options;
 
 namespace Benchmarks.Data
 {
@@ -11,51 +16,64 @@ namespace Benchmarks.Data
     {
         private readonly IRandom _random;
         private readonly ApplicationDbContext _dbContext;
+        private readonly bool _useBatchUpdate;
 
-        public EfDb(IRandom random, ApplicationDbContext dbContext)
+        public EfDb(IRandom random, ApplicationDbContext dbContext, IOptions<AppSettings> appSettings)
         {
             _random = random;
             _dbContext = dbContext;
-            _dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
+            _useBatchUpdate = appSettings.Value.Database != DatabaseServer.PostgreSql;
         }
 
+        private static readonly Func<ApplicationDbContext, int, Task<World>> _firstWorldQuery
+            = EF.CompileAsyncQuery((ApplicationDbContext context, int id)
+                => context.World.First(w => w.Id == id));
+
         public Task<World> LoadSingleQueryRow()
         {
             var id = _random.Next(1, 10001);
-            return _dbContext.World.FirstAsync(w => w.Id == id);
+
+            return _firstWorldQuery(_dbContext, id);
         }
 
         public async Task<World[]> LoadMultipleQueriesRows(int count)
         {
             var result = new World[count];
 
-            for (int i = 0; i < count; i++)
+            for (var i = 0; i < count; i++)
             {
                 var id = _random.Next(1, 10001);
-                result[i] = await _dbContext.World.FirstAsync(w => w.Id == id);
+
+                result[i] = await _firstWorldQuery(_dbContext, id);
             }
 
             return result;
         }
 
+        private static readonly Func<ApplicationDbContext, int, Task<World>> _firstWorldTrackedQuery
+            = EF.CompileAsyncQuery((ApplicationDbContext context, int id)
+                => context.World.AsTracking().First(w => w.Id == id));
+
         public async Task<World[]> LoadMultipleUpdatesRows(int count)
         {
             var results = new World[count];
 
-            for (int i = 0; i < count; i++)
+            for (var i = 0; i < count; i++)
             {
                 var id = _random.Next(1, 10001);
-                var result = await _dbContext.World.AsTracking().FirstAsync(w => w.Id == id);
+                var result = await _firstWorldTrackedQuery(_dbContext, id);
+
+                _dbContext.Entry(result).Property("RandomNumber").CurrentValue = _random.Next(1, 10001);
 
-                result.RandomNumber = _random.Next(1, 10001);
                 results[i] = result;
-                if(!_dbContext.UseBatchUpdate)
+
+                if (!_useBatchUpdate)
                 {
                     await _dbContext.SaveChangesAsync();
                 }
             }
-            
-            if(_dbContext.UseBatchUpdate)
+
+            if (_useBatchUpdate)
             {
                 await _dbContext.SaveChangesAsync();
             }
@@ -63,9 +81,12 @@ namespace Benchmarks.Data
             return results;
         }
 
+        private static readonly Func<ApplicationDbContext, AsyncEnumerable<Fortune>> _fortunesQuery
+            = EF.CompileAsyncQuery((ApplicationDbContext context) => context.Fortune);
+
         public async Task<IEnumerable<Fortune>> LoadFortunesRows()
         {
-            var result = await _dbContext.Fortune.ToListAsync();
+            var result = await _fortunesQuery(_dbContext).ToListAsync();
 
             result.Add(new Fortune { Message = "Additional fortune added at request time." });
             result.Sort();

+ 0 - 43
frameworks/CSharp/aspnetcore/Benchmarks/Data/NoTransactionSqlServerConnection.cs

@@ -1,43 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
-
-using System.Data;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage;
-using Microsoft.EntityFrameworkCore.Storage.Internal;
-using Microsoft.Extensions.Logging;
-
-namespace Benchmarks.Data
-{
-    class NoTransactionSqlServerConnection : SqlServerConnection
-    {
-        public NoTransactionSqlServerConnection(IDbContextOptions options, ILogger<SqlServerConnection> logger)
-            : base(options, logger)
-        {
-        }
-
-        public override Task<IDbContextTransaction> BeginTransactionAsync(
-            IsolationLevel isolationLevel, CancellationToken cancellationToken = new CancellationToken())
-            => Task.FromResult<IDbContextTransaction>(new FakeTransaction());
-
-        public override IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) 
-            => new FakeTransaction();
-
-        private class FakeTransaction : IDbContextTransaction
-        {
-            public void Dispose()
-            {
-            }
-
-            public void Commit()
-            {
-            }
-
-            public void Rollback()
-            {
-            }
-        }
-    }
-}

+ 8 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Data/RawDb.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Collections.Generic;
@@ -17,7 +17,7 @@ namespace Benchmarks.Data
         private readonly IRandom _random;
         private readonly DbProviderFactory _dbProviderFactory;
         private readonly string _connectionString;
-        
+
         public RawDb(IRandom random, DbProviderFactory dbProviderFactory, IOptions<AppSettings> appSettings)
         {
             _random = random;
@@ -38,7 +38,7 @@ namespace Benchmarks.Data
                 }
             }
         }
-        
+
         async Task<World> ReadSingleRow(DbConnection connection, DbCommand cmd)
         {
             using (var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow))
@@ -94,7 +94,7 @@ namespace Benchmarks.Data
         public async Task<World[]> LoadMultipleUpdatesRows(int count)
         {
             var results = new World[count];
-           
+
             var updateCommand = new StringBuilder(count);
 
             using (var db = _dbProviderFactory.CreateConnection())
@@ -111,7 +111,7 @@ namespace Benchmarks.Data
                         queryCmd.Parameters["@Id"].Value = _random.Next(1, 10001);
                     }
 
-                    // postgres has problems with deadlocks when these aren't sorted
+                    // Postgres has problems with deadlocks when these aren't sorted
                     Array.Sort<World>(results, (a, b) => a.Id.CompareTo(b.Id));
 
                     for(int i = 0; i < count; i++)
@@ -123,7 +123,7 @@ namespace Benchmarks.Data
 
                         var random = updateCmd.CreateParameter();
                         random.ParameterName = BatchUpdateString.Strings[i].Random;
-                        id.DbType = DbType.Int32;
+                        random.DbType = DbType.Int32;
                         updateCmd.Parameters.Add(random);
 
                         var randomNumber = _random.Next(1, 10001);
@@ -135,6 +135,7 @@ namespace Benchmarks.Data
                     }
 
                     updateCmd.CommandText = updateCommand.ToString();
+                    updateCmd.Prepare();
                     await updateCmd.ExecuteNonQueryAsync();
                 }
             }

+ 4 - 4
frameworks/CSharp/aspnetcore/Benchmarks/Data/World.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System.ComponentModel.DataAnnotations.Schema;
 
@@ -8,10 +8,10 @@ namespace Benchmarks.Data
     [Table("world")]
     public class World
     {
-        [Column("id")] 
+        [Column("id")]
         public int Id { get; set; }
 
-        [Column("randomnumber")] 
+        [Column("randomnumber")]
         public int RandomNumber { get; set; }
     }
 }

+ 7 - 4
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/DebugInfoPageMiddleware.cs

@@ -1,6 +1,7 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
+using System;
 using System.Linq;
 using System.Runtime;
 using System.Threading.Tasks;
@@ -10,7 +11,6 @@ using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting.Server.Features;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http.Features;
-using Microsoft.Extensions.PlatformAbstractions;
 
 namespace Benchmarks.Middleware
 {
@@ -24,6 +24,8 @@ namespace Benchmarks.Middleware
         private static readonly string _configurationName = "";
 #endif
 
+        private static readonly string _targetFrameworkName = AppContext.TargetFrameworkName;
+
         private readonly IHostingEnvironment _hostingEnv;
         private readonly RequestDelegate _next;
         private readonly Scenarios _scenarios;
@@ -40,13 +42,14 @@ namespace Benchmarks.Middleware
         public async Task Invoke(HttpContext httpContext)
         {
             httpContext.Response.ContentType = "text/html";
+            httpContext.Response.StatusCode = StatusCodes.Status404NotFound;
 
             await httpContext.Response.WriteAsync("<!DOCTYPE html><html><head><style>body{font-family:\"Segoe UI\",Arial,Helvetica,Sans-serif};h1,h2,h3{font-family:\"Segoe UI Light\"}</style></head><body>");
             await httpContext.Response.WriteAsync("<h1>ASP.NET Core Benchmarks</h1>");
             await httpContext.Response.WriteAsync("<h2>Configuration Information</h2>");
             await httpContext.Response.WriteAsync("<ul>");
             await httpContext.Response.WriteAsync($"<li>Environment: {_hostingEnv.EnvironmentName}</li>");
-            await httpContext.Response.WriteAsync($"<li>Framework: {PlatformServices.Default.Application.RuntimeFramework.FullName}</li>");
+            await httpContext.Response.WriteAsync($"<li>Framework: {_targetFrameworkName}</li>");
             await httpContext.Response.WriteAsync($"<li>Server GC enabled: {GCSettings.IsServerGC}</li>");
             await httpContext.Response.WriteAsync($"<li>Configuration: {_configurationName}</li>");
             await httpContext.Response.WriteAsync($"<li>Server: {Program.Server}</li>");

+ 7 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesDapperMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Text.Encodings.Web;
@@ -8,6 +8,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Benchmarks.Middleware
 {
@@ -16,13 +17,11 @@ namespace Benchmarks.Middleware
         private static readonly PathString _path = new PathString(Scenarios.GetPath(s => s.DbFortunesDapper));
 
         private readonly RequestDelegate _next;
-        private readonly DapperDb _db;
         private readonly HtmlEncoder _htmlEncoder;
 
-        public FortunesDapperMiddleware(RequestDelegate next, DapperDb db, HtmlEncoder htmlEncoder)
+        public FortunesDapperMiddleware(RequestDelegate next, HtmlEncoder htmlEncoder)
         {
             _next = next;
-            _db = db;
             _htmlEncoder = htmlEncoder;
         }
 
@@ -30,7 +29,8 @@ namespace Benchmarks.Middleware
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var rows = await _db.LoadFortunesRows();
+                var db = httpContext.RequestServices.GetService<DapperDb>();
+                var rows = await db.LoadFortunesRows();
 
                 await MiddlewareHelpers.RenderFortunesHtml(rows, httpContext, _htmlEncoder);
 
@@ -40,7 +40,7 @@ namespace Benchmarks.Middleware
             await _next(httpContext);
         }
     }
-    
+
     public static class FortunesDapperMiddlewareExtensions
     {
         public static IApplicationBuilder UseFortunesDapper(this IApplicationBuilder builder)

+ 3 - 3
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesEfMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Text.Encodings.Web;
@@ -40,7 +40,7 @@ namespace Benchmarks.Middleware
             await _next(httpContext);
         }
     }
-    
+
     public static class FortunesEfMiddlewareExtensions
     {
         public static IApplicationBuilder UseFortunesEf(this IApplicationBuilder builder)

+ 7 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/FortunesRawMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Text.Encodings.Web;
@@ -8,6 +8,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Benchmarks.Middleware
 {
@@ -16,13 +17,11 @@ namespace Benchmarks.Middleware
         private static readonly PathString _path = new PathString(Scenarios.GetPath(s => s.DbFortunesRaw));
 
         private readonly RequestDelegate _next;
-        private readonly RawDb _db;
         private readonly HtmlEncoder _htmlEncoder;
 
-        public FortunesRawMiddleware(RequestDelegate next, RawDb db, HtmlEncoder htmlEncoder)
+        public FortunesRawMiddleware(RequestDelegate next, HtmlEncoder htmlEncoder)
         {
             _next = next;
-            _db = db;
             _htmlEncoder = htmlEncoder;
         }
 
@@ -30,7 +29,8 @@ namespace Benchmarks.Middleware
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var rows = await _db.LoadFortunesRows();
+                var db = httpContext.RequestServices.GetService<RawDb>();
+                var rows = await db.LoadFortunesRows();
 
                 await MiddlewareHelpers.RenderFortunesHtml(rows, httpContext, _htmlEncoder);
 
@@ -40,7 +40,7 @@ namespace Benchmarks.Middleware
             await _next(httpContext);
         }
     }
-    
+
     public static class FortunesRawMiddlewareExtensions
     {
         public static IApplicationBuilder UseFortunesRaw(this IApplicationBuilder builder)

+ 5 - 6
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/JsonMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.IO;
@@ -14,14 +14,13 @@ namespace Benchmarks.Middleware
 {
     public class JsonMiddleware
     {
-        private static readonly Task _done = Task.FromResult(0);
         private static readonly PathString _path = new PathString(Scenarios.GetPath(s => s.Json));
         private static readonly JsonSerializer _json = new JsonSerializer();
         private static readonly UTF8Encoding _encoding = new UTF8Encoding(false);
         private const int _bufferSize = 27;
 
         private readonly RequestDelegate _next;
-        
+
         public JsonMiddleware(RequestDelegate next)
         {
             _next = next;
@@ -40,13 +39,13 @@ namespace Benchmarks.Middleware
                     _json.Serialize(sw, new { message = "Hello, World!" });
                 }
 
-                return _done;
+                return Task.CompletedTask;
             }
 
             return _next(httpContext);
         }
     }
-    
+
     public static class JsonMiddlewareExtensions
     {
         public static IApplicationBuilder UseJson(this IApplicationBuilder builder)

+ 7 - 6
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesDapperMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,12 +22,10 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly DapperDb _db;
 
-        public MultipleQueriesDapperMiddleware(RequestDelegate next, DapperDb db)
+        public MultipleQueriesDapperMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
@@ -34,7 +33,9 @@ namespace Benchmarks.Middleware
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
-                var rows = await _db.LoadMultipleQueriesRows(count);
+
+                var db = httpContext.RequestServices.GetService<DapperDb>();
+                var rows = await db.LoadMultipleQueriesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);
 

+ 4 - 3
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesEfMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -32,8 +32,9 @@ namespace Benchmarks.Middleware
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var db = httpContext.RequestServices.GetService<EfDb>();
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
+
+                var db = httpContext.RequestServices.GetService<EfDb>();
                 var rows = await db.LoadMultipleQueriesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);

+ 7 - 6
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleQueriesRawMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,12 +22,10 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly RawDb _db;
 
-        public MultipleQueriesRawMiddleware(RequestDelegate next, RawDb db)
+        public MultipleQueriesRawMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
@@ -34,7 +33,9 @@ namespace Benchmarks.Middleware
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
-                var rows = await _db.LoadMultipleQueriesRows(count);
+
+                var db = httpContext.RequestServices.GetService<RawDb>();
+                var rows = await db.LoadMultipleQueriesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);
 

+ 8 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesDapperMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,12 +22,10 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly DapperDb _db;
 
-        public MultipleUpdatesDapperMiddleware(RequestDelegate next, DapperDb db)
+        public MultipleUpdatesDapperMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
@@ -34,7 +33,9 @@ namespace Benchmarks.Middleware
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
-                var rows = await _db.LoadMultipleUpdatesRows(count);
+
+                var db = httpContext.RequestServices.GetService<DapperDb>();
+                var rows = await db.LoadMultipleUpdatesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);
 
@@ -58,4 +59,4 @@ namespace Benchmarks.Middleware
             return builder.UseMiddleware<MultipleUpdatesDapperMiddleware>();
         }
     }
-}
+}

+ 4 - 3
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesEfMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -32,8 +32,9 @@ namespace Benchmarks.Middleware
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var db = httpContext.RequestServices.GetService<EfDb>();
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
+
+                var db = httpContext.RequestServices.GetService<EfDb>();
                 var rows = await db.LoadMultipleUpdatesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);

+ 8 - 7
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/MultipleUpdatesRawMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,12 +22,10 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly RawDb _db;
 
-        public MultipleUpdatesRawMiddleware(RequestDelegate next, RawDb db)
+        public MultipleUpdatesRawMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
@@ -34,7 +33,9 @@ namespace Benchmarks.Middleware
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
                 var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext);
-                var rows = await _db.LoadMultipleUpdatesRows(count);
+
+                var db = httpContext.RequestServices.GetService<RawDb>();
+                var rows = await db.LoadMultipleUpdatesRows(count);
 
                 var result = JsonConvert.SerializeObject(rows, _jsonSettings);
 
@@ -58,4 +59,4 @@ namespace Benchmarks.Middleware
             return builder.UseMiddleware<MultipleUpdatesRawMiddleware>();
         }
     }
-}
+}

+ 14 - 10
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/PlaintextMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Text;
@@ -16,7 +16,7 @@ namespace Benchmarks.Middleware
         private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
 
         private readonly RequestDelegate _next;
-        
+
         public PlaintextMiddleware(RequestDelegate next)
         {
             _next = next;
@@ -26,18 +26,22 @@ namespace Benchmarks.Middleware
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                httpContext.Response.StatusCode = 200;
-                httpContext.Response.ContentType = "text/plain";
-                // HACK: Setting the Content-Length header manually avoids the cost of serializing the int to a string.
-                //       This is instead of: httpContext.Response.ContentLength = _helloWorldPayload.Length;
-                httpContext.Response.Headers["Content-Length"] = "13";
-                return httpContext.Response.Body.WriteAsync(_helloWorldPayload, 0, _helloWorldPayload.Length);
+                return WriteResponse(httpContext.Response);
             }
 
             return _next(httpContext);
         }
+
+        public static Task WriteResponse(HttpResponse response)
+        {
+            var payloadLength = _helloWorldPayload.Length;
+            response.StatusCode = 200;
+            response.ContentType = "text/plain";
+            response.ContentLength = payloadLength;
+            return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
+        }
     }
-    
+
     public static class PlaintextMiddlewareExtensions
     {
         public static IApplicationBuilder UsePlainText(this IApplicationBuilder builder)

+ 6 - 6
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryDapperMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,19 +22,18 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly DapperDb _db;
 
-        public SingleQueryDapperMiddleware(RequestDelegate next, DapperDb db)
+        public SingleQueryDapperMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var row = await _db.LoadSingleQueryRow();
+                var db = httpContext.RequestServices.GetService<DapperDb>();
+                var row = await db.LoadSingleQueryRow();
 
                 var result = JsonConvert.SerializeObject(row, _jsonSettings);
 

+ 2 - 2
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryEfMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;

+ 6 - 6
frameworks/CSharp/aspnetcore/Benchmarks/Middleware/SingleQueryRawMiddleware.cs

@@ -1,5 +1,5 @@
-// Copyright (c) .NET Foundation. All rights reserved. 
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
 
 using System;
 using System.Threading.Tasks;
@@ -7,6 +7,7 @@ using Benchmarks.Configuration;
 using Benchmarks.Data;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 
@@ -21,19 +22,18 @@ namespace Benchmarks.Middleware
         };
 
         private readonly RequestDelegate _next;
-        private readonly RawDb _db;
 
-        public SingleQueryRawMiddleware(RequestDelegate next, RawDb db)
+        public SingleQueryRawMiddleware(RequestDelegate next)
         {
             _next = next;
-            _db = db;
         }
 
         public async Task Invoke(HttpContext httpContext)
         {
             if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
             {
-                var row = await _db.LoadSingleQueryRow();
+                var db = httpContext.RequestServices.GetService<RawDb>();
+                var row = await db.LoadSingleQueryRow();
 
                 var result = JsonConvert.SerializeObject(row, _jsonSettings);
 

+ 15 - 11
frameworks/CSharp/aspnetcore/Benchmarks/Program.cs

@@ -3,6 +3,7 @@
 
 using System;
 using System.IO;
+using System.Reflection;
 using System.Runtime;
 using System.Threading;
 using Benchmarks.Configuration;
@@ -26,6 +27,7 @@ namespace Benchmarks
             Console.WriteLine("-----------------------");
 
             Console.WriteLine($"Current directory: {Directory.GetCurrentDirectory()}");
+            Console.WriteLine($"WebHostBuilder loading from: {typeof(WebHostBuilder).GetTypeInfo().Assembly.Location}");
 
             var config = new ConfigurationBuilder()
                 .AddCommandLine(args)
@@ -43,22 +45,22 @@ namespace Benchmarks
                     .AddSingleton(new ConsoleArgs(args))
                     .AddSingleton<IScenariosConfiguration, ConsoleHostScenariosConfiguration>()
                     .AddSingleton<Scenarios>()
-                );
+                )
+                .UseDefaultServiceProvider(
+                    (context, options) => options.ValidateScopes = context.HostingEnvironment.IsDevelopment());
 
             if (String.Equals(Server, "Kestrel", StringComparison.OrdinalIgnoreCase))
             {
                 var threads = GetThreadCount(config);
-                webHostBuilder = webHostBuilder.UseKestrel((options) =>
+                webHostBuilder = webHostBuilder.UseKestrel();
+                if (threads > 0)
                 {
-                    if (threads > 0)
-                    {
-                        options.ThreadCount = threads;
-                    }
-                });
+                    webHostBuilder = webHostBuilder.UseLibuv(options => options.ThreadCount = threads);
+                }
             }
-            else if (String.Equals(Server, "WebListener", StringComparison.OrdinalIgnoreCase))
+            else if (String.Equals(Server, "HttpSys", StringComparison.OrdinalIgnoreCase))
             {
-                webHostBuilder = webHostBuilder.UseWebListener();
+                webHostBuilder = webHostBuilder.UseHttpSys();
             }
             else
             {
@@ -113,9 +115,11 @@ namespace Benchmarks
                         Console.WriteLine($"Gen 0: {GC.CollectionCount(0)}, Gen 1: {GC.CollectionCount(1)}, Gen 2: {GC.CollectionCount(2)}");
                     }
                 }
-            });
+            })
+            {
+                IsBackground = true
+            };
 
-            interactiveThread.IsBackground = true;
             interactiveThread.Start();
 
             started.WaitOne();

+ 0 - 27
frameworks/CSharp/aspnetcore/Benchmarks/Properties/launchSettings.json

@@ -1,27 +0,0 @@
-{
-  "iisSettings": {
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    "iisExpress": {
-      "applicationUrl": "http://localhost:3653/",
-      "sslPort": 0
-    }
-  },
-  "profiles": {
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "environmentVariables": {
-        "EnableDbTests": "true",
-        "AspNet_Environment": "Development"
-      }
-    },
-    "Benchmarks": {
-      "commandName": "Benchmarks",
-      "launchUrl": "http://localhost:5000/",
-      "environmentVariables": {
-        "AspNet_Environment": "Development"
-      }
-    }
-  }
-}

+ 21 - 24
frameworks/CSharp/aspnetcore/Benchmarks/Startup.cs

@@ -11,10 +11,9 @@ using Benchmarks.Data;
 using Benchmarks.Middleware;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
+using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Options;
-using Microsoft.Extensions.PlatformAbstractions;
 using Npgsql;
 
 namespace Benchmarks
@@ -25,7 +24,7 @@ namespace Benchmarks
         {
             // Set up configuration sources.
             var builder = new ConfigurationBuilder()
-                .SetBasePath(PlatformServices.Default.Application.ApplicationBasePath)
+                .SetBasePath(hostingEnv.ContentRootPath)
                 .AddCommandLine(Program.Args)
                 .AddJsonFile("appsettings.json")
                 .AddJsonFile($"appsettings.{hostingEnv.EnvironmentName}.json", optional: true)
@@ -51,23 +50,24 @@ namespace Benchmarks
             // Common DB services
             services.AddSingleton<IRandom, DefaultRandom>();
             services.AddSingleton<ApplicationDbSeeder>();
-            services.AddEntityFrameworkSqlServer()
-                .AddDbContext<ApplicationDbContext>();
-            
-            if (Scenarios.Any("Raw") || Scenarios.Any("Dapper"))
-            {
-                services.AddSingleton<DbProviderFactory>((provider) => {
-                    var settings = provider.GetRequiredService<IOptions<AppSettings>>().Value;
-
-                    if (settings.Database == DatabaseServer.PostgreSql)
-                    {
-                        return NpgsqlFactory.Instance;
-                    }
-                    else
-                    {
-                        return SqlClientFactory.Instance;
-                    }
-                });
+            services.AddEntityFrameworkSqlServer();
+
+            var appSettings = Configuration.Get<AppSettings>();
+            if (appSettings.Database == DatabaseServer.PostgreSql)
+            {
+                services.AddDbContextPool<ApplicationDbContext>(options => options.UseNpgsql(appSettings.ConnectionString));
+                if (Scenarios.Any("Raw") || Scenarios.Any("Dapper"))
+                {
+                    services.AddSingleton<DbProviderFactory>(NpgsqlFactory.Instance);
+                }
+            }
+            else
+            {
+                services.AddDbContextPool<ApplicationDbContext>(options => options.UseSqlServer(appSettings.ConnectionString));
+                if (Scenarios.Any("Raw") || Scenarios.Any("Dapper"))
+                {
+                    services.AddSingleton<DbProviderFactory>(SqlClientFactory.Instance);
+                }
             }
 
             if (Scenarios.Any("Ef"))
@@ -99,7 +99,6 @@ namespace Benchmarks
             {
                 var mvcBuilder = services
                     .AddMvcCore()
-                    //.AddApplicationPart(typeof(Startup).GetTypeInfo().Assembly)
                     .AddControllersAsServices();
 
                 if (Scenarios.MvcJson || Scenarios.Any("MvcDbSingle") || Scenarios.Any("MvcDbMulti"))
@@ -116,7 +115,7 @@ namespace Benchmarks
             }
         }
 
-        public void Configure(IApplicationBuilder app, ApplicationDbSeeder dbSeeder, ApplicationDbContext dbContext)
+        public void Configure(IApplicationBuilder app, ApplicationDbSeeder dbSeeder)
         {
             if (Scenarios.Plaintext)
             {
@@ -194,8 +193,6 @@ namespace Benchmarks
 
             if (Scenarios.Any("Db"))
             {
-                dbContext.Database.EnsureCreated();
-
                 if (!dbSeeder.Seed())
                 {
                     Environment.Exit(1);

+ 3 - 0
frameworks/CSharp/aspnetcore/Benchmarks/appsettings.json

@@ -0,0 +1,3 @@
+{
+  "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnetcore-Benchmarks;Trusted_Connection=True;MultipleActiveResultSets=true"
+}

+ 0 - 59
frameworks/CSharp/aspnetcore/Benchmarks/project.json

@@ -1,59 +0,0 @@
-{
-  "version": "1.0.0-*",
-  "buildOptions": {
-    "emitEntryPoint": true,
-    "preserveCompilationContext": true,
-    "copyToOutput": {
-      "include": [
-        "appsettings.json",
-        "wwwroot",
-        "Views"
-      ]
-    }
-  },
-  "dependencies": {
-    "Dapper": "1.50.2",
-    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
-    "Microsoft.EntityFrameworkCore.Tools": {
-      "type": "build",
-      "version": "1.1.0-preview4-final"
-    },
-    "Microsoft.AspNetCore.Mvc": "1.1.0",
-    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
-    "Microsoft.AspNetCore.Server.WebListener": "1.1.0",
-    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
-    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
-    "Microsoft.Extensions.Configuration.Json": "1.1.0",
-    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
-    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
-    "Npgsql": "3.2.0-beta1",
-    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0"
-  },
-  "frameworks": {
-    "netcoreapp1.1": {
-      "dependencies": {
-        "Microsoft.NETCore.App": {
-          "version": "1.1.0",
-          "type": "platform"
-        },
-        "System.Runtime.Serialization.Primitives": "4.3.0"
-      }
-    }
-  },
-  "tools": {
-    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
-  },
-  "publishOptions": {
-    "include": [
-      "appsettings.json",
-      "wwwroot",
-      "Views"
-    ]
-  },
-  "runtimeOptions": {
-    "configProperties": {
-      "System.GC.Server": true
-    }
-  }
-}
-

+ 3 - 3
frameworks/CSharp/aspnetcore/README.md

@@ -8,7 +8,7 @@ This includes tests for plaintext and json serialization.
 
 **Language**
 
-* C# 6.0
+* C# 7.0
 
 **Platforms**
 
@@ -16,8 +16,8 @@ This includes tests for plaintext and json serialization.
 
 **Web Servers**
 
-* [Kestrel](https://github.com/aspnet/kestrelHttpServer)
-* WebListener
+* [Kestrel](https://github.com/aspnet/KestrelHttpServer)
+* [HttpSys](https://github.com/aspnet/HttpSysServer)
 
 **Web Stack**
 

+ 11 - 12
frameworks/CSharp/aspnetcore/benchmark_config.json

@@ -10,7 +10,6 @@
       "database": "None",
       "framework": "aspnetcore",
       "language": "C#",
-      "flavor": "Mono",
       "orm": "Raw",
       "platform": "NET",
       "flavor": "CoreCLR",
@@ -107,7 +106,7 @@
       "versus": ""
     },
     "mvc-linux": {
-      "setup_file": "setup-plaintext",
+      "setup_file": "setup-mvc-plaintext",
       "plaintext_url": "/mvc/plaintext",
       "port": 8080,
       "approach": "Realistic",
@@ -126,7 +125,7 @@
       "versus": ""
     },
     "mvc-linux-json": {
-      "setup_file": "setup-json",
+      "setup_file": "setup-mvc-json",
       "json_url": "/mvc/json",
       "port": 8080,
       "approach": "Realistic",
@@ -145,7 +144,7 @@
       "versus": ""
     },
     "mvc-raw": {
-      "setup_file": "setup-raw",
+      "setup_file": "setup-mvc-raw",
       "db_url": "/mvc/db/raw",
       "query_url": "/mvc/queries/raw?queries=",
       "update_url": "/mvc/updates/raw?queries=",
@@ -167,7 +166,7 @@
       "versus": ""
     },
     "mvc-ef": {
-      "setup_file": "setup-ef",
+      "setup_file": "setup-mvc-ef",
       "db_url": "/mvc/db/ef",
       "query_url": "/mvc/queries/ef?queries=",
       "update_url": "/mvc/updates/ef?queries=",
@@ -189,7 +188,7 @@
       "versus": ""
     },
     "mvc-dapper": {
-      "setup_file": "setup-dapper",
+      "setup_file": "setup-mvc-dapper",
       "db_url": "/mvc/db/dapper",
       "query_url": "/mvc/queries/dapper?queries=",
       "update_url": "/mvc/updates/dapper?queries=",
@@ -250,8 +249,8 @@
       "notes": "",
       "versus": ""
     },
-    "weblistener": {
-      "setup_file": "setup-weblistener",
+    "httpsys": {
+      "setup_file": "setup-httpsys",
       "json_url": "/json",
       "plaintext_url": "/plaintext",
       "port": 8080,
@@ -266,12 +265,12 @@
       "webserver": "None",
       "os": "Windows",
       "database_os": "Linux",
-      "display_name": "aspnetcore-weblistener",
+      "display_name": "aspnetcore-httpsys",
       "notes": "",
       "versus": ""
     },
-    "mvc-weblistener": {
-      "setup_file": "setup-mvc-weblistener",
+    "mvc-httpsys": {
+      "setup_file": "setup-mvc-httpsys",
       "json_url": "/mvc/json",
       "plaintext_url": "/mvc/plaintext",
       "port": 8080,
@@ -286,7 +285,7 @@
       "webserver": "None",
       "os": "Windows",
       "database_os": "Linux",
-      "display_name": "aspnetcore-mvc-weblistener",
+      "display_name": "aspnetcore-mvc-httpsys",
       "notes": "",
       "versus": ""
     }

+ 2 - 2
frameworks/CSharp/aspnetcore/run-linux.sh

@@ -11,6 +11,6 @@ cd Benchmarks
 cp appsettings.postgresql.json appsettings.json
 sed -i 's|{db_server_placeholder}|'"${DBHOST}"'|g' appsettings.json
 dotnet restore
-dotnet build -c Release
+dotnet publish --configuration Release --output bin/Release/publish
 
-dotnet bin/Release/netcoreapp1.1/Benchmarks.dll server.urls=http://*:8080 scenarios=$1 server=kestrel threadCount=$threadCount NonInteractive=true &
+dotnet bin/Release/publish/Benchmarks.dll server.urls=http://*:8080 scenarios=$1 server=kestrel threadCount=$threadCount NonInteractive=true &

+ 2 - 2
frameworks/CSharp/aspnetcore/run-windows.ps1

@@ -4,5 +4,5 @@ $scenarios = (-split $scenarios) -join ","
 
 cd Benchmarks
 dotnet restore
-dotnet build -c Release
-Start-Process -NoNewWindow dotnet "bin\Release\netcoreapp1.1\Benchmarks.dll server.urls=http://*:8080 server=$server threadCount=1 NonInteractive=true scenarios=$scenarios"
+dotnet publish --configuration Release --output bin\Release\publish
+Start-Process -NoNewWindow dotnet -ArgumentList "bin\Release\publish\Benchmarks.dll", "server.urls=http://*:8080", "server=$server", "threadCount=1", "NonInteractive=true", "scenarios=$scenarios"

+ 1 - 1
frameworks/CSharp/aspnetcore/setup-dapper.sh

@@ -2,4 +2,4 @@
 
 fw_depends postgresql
 
-source run-linux.sh dapper $(($(nproc)/2))
+source run-linux.sh 'DbSingleQueryDapper,DbMultiQueryDapper,DbMultiUpdateDapper,DbFortunesDapper' $(($(nproc)/2))

+ 1 - 1
frameworks/CSharp/aspnetcore/setup-ef.sh

@@ -2,4 +2,4 @@
 
 fw_depends postgresql
 
-source run-linux.sh ef $(($(nproc)/2))
+source run-linux.sh 'DbSingleQueryEf,DbMultiQueryEf,DbMultiUpdateEf,DbFortunesEf' $(($(nproc)/2))

+ 3 - 0
frameworks/CSharp/aspnetcore/setup-httpsys.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+fw_depends dotnetcore
+powershell ./run-windows.ps1 -scenarios [default] -server httpsys

+ 5 - 0
frameworks/CSharp/aspnetcore/setup-mvc-dapper.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+fw_depends postgresql
+
+source run-linux.sh 'MvcDbSingleQueryDapper,MvcDbMultiQueryDapper,MvcDbMultiUpdateDapper,MvcDbFortunesDapper' $(($(nproc)/2))

+ 5 - 0
frameworks/CSharp/aspnetcore/setup-mvc-ef.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+fw_depends postgresql
+
+source run-linux.sh 'MvcDbSingleQueryEf,MvcDbMultiQueryEf,MvcDbMultiUpdateEf,MvcDbFortunesEf' $(($(nproc)/2))

+ 3 - 0
frameworks/CSharp/aspnetcore/setup-mvc-httpsys.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+fw_depends dotnetcore
+powershell ./run-windows.ps1 -scenarios 'mvcjson,mvcplain' -server httpsys

+ 3 - 0
frameworks/CSharp/aspnetcore/setup-mvc-json.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+source run-linux.sh mvcjson $(nproc)

+ 3 - 0
frameworks/CSharp/aspnetcore/setup-mvc-plaintext.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+source run-linux.sh mvcplaintext $(($(nproc)*3/10))

+ 5 - 0
frameworks/CSharp/aspnetcore/setup-mvc-raw.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+fw_depends postgresql
+
+source run-linux.sh 'MvcDbSingleQueryRaw,MvcDbMultiQueryRaw,MvcDbMultiUpdateRaw,MvcDbFortunesRaw' $(($(nproc)/2))

+ 0 - 3
frameworks/CSharp/aspnetcore/setup-mvc-weblistener.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-fw_depends dotnetcore
-powershell run-windows.ps1 -scenarios 'mvcjson,mvcplain' -server weblistener

+ 1 - 1
frameworks/CSharp/aspnetcore/setup-mvc-windows.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 fw_depends dotnetcore
-powershell run-windows.ps1 -scenarios 'mvcjson,mvcplain' -server kestrel
+powershell ./run-windows.ps1 -scenarios 'mvcjson,mvcplain' -server kestrel

+ 1 - 1
frameworks/CSharp/aspnetcore/setup-raw.sh

@@ -2,4 +2,4 @@
 
 fw_depends postgresql
 
-source run-linux.sh raw $(($(nproc)/2))
+source run-linux.sh 'DbSingleQueryRaw,DbMultiQueryRaw,DbMultiUpdateRaw,DbFortunesRaw' $(($(nproc)/2))

+ 0 - 3
frameworks/CSharp/aspnetcore/setup-weblistener.sh

@@ -1,3 +0,0 @@
-#!/bin/bash
-fw_depends dotnetcore
-powershell run-windows.ps1 -scenarios [default] -server weblistener

+ 1 - 1
frameworks/CSharp/aspnetcore/setup-windows.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 fw_depends dotnetcore
-powershell run-windows.ps1 -scenarios [default] -server kestrel
+powershell ./run-windows.ps1 -scenarios [default] -server kestrel

+ 1 - 1
toolset/setup/linux/languages/dotnetcore.sh

@@ -6,7 +6,7 @@ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotne
 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
 sudo apt-get update
 
-sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177 -y
+sudo apt-get install -y dotnet-dev-2.0.0-preview1-005977
 echo "PATH=$HOME/.dotnet:$PATH" > $IROOT/dotnetcore.installed
 
 source $IROOT/dotnetcore.installed