From 3849c96ffc752c0cd5d6d0e95e416a222312c3e1 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 09:42:03 +0000 Subject: [PATCH 1/8] Rehabilitate the old BlazingPizza.Server benchmark app. Make it use the framework built from sources. --- AspNetCore.sln | 19 ++ src/Components/Components.slnf | 1 + .../BlazingPizza.Server.csproj | 11 + .../BlazingPizza.Server/Directory.Build.props | 2 - .../Directory.Build.targets | 3 - .../JSRuntimeExtensions.cs | 14 +- .../BlazingPizza.Server/Model/Address.cs | 35 ++- .../BlazingPizza.Server/Model/LatLong.cs | 37 ++- .../BlazingPizza.Server/Model/Order.cs | 27 +- .../BlazingPizza.Server/Model/OrderState.cs | 64 +++++ .../BlazingPizza.Server/Model/Pizza.cs | 56 ++--- .../BlazingPizza.Server/Model/PizzaSpecial.cs | 27 +- .../BlazingPizza.Server/Model/PizzaTopping.cs | 15 +- .../BlazingPizza.Server/Model/Point.cs | 11 +- .../Model/SpecialsService.cs | 74 ++++++ .../BlazingPizza.Server/Model/Topping.cs | 17 +- .../BlazingPizza.Server/Model/UserInfo.cs | 9 - .../BlazingPizza.Server/NuGet.config | 7 - .../BlazingPizza.Server/OrderState.cs | 68 ----- .../BlazingPizza.Server/Pages/Checkout.razor | 4 +- .../BlazingPizza.Server/Pages/_Host.cshtml | 17 +- .../BlazingPizza.Server/Program.cs | 48 ++-- .../Properties/launchSettings.json | 12 + .../BlazingPizza.Server/SpecialsService.cs | 77 ------ .../BlazingPizza.Server/Startup.cs | 58 ----- .../BlazingPizza.Server/ToppingsService.cs | 235 +++++++++--------- .../BlazingPizza.Server/_Imports.razor | 1 + 27 files changed, 450 insertions(+), 499 deletions(-) delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets create mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs create mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs create mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs diff --git a/AspNetCore.sln b/AspNetCore.sln index 6bd60d448dbe..d1d7253fee6a 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1770,6 +1770,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Compon EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter", "src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter\src\Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter.csproj", "{F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazingPizza.Server", "src\Components\benchmarkapps\BlazingPizza.Server\BlazingPizza.Server.csproj", "{A05652B3-953E-4915-9D7F-0E361D988815}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -10627,6 +10629,22 @@ Global {F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x64.Build.0 = Release|Any CPU {F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.ActiveCfg = Release|Any CPU {F0BF2260-5AE2-4248-81DE-AC5B9FC6A931}.Release|x86.Build.0 = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|arm64.ActiveCfg = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|arm64.Build.0 = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x64.ActiveCfg = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x64.Build.0 = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x86.ActiveCfg = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Debug|x86.Build.0 = Debug|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|Any CPU.Build.0 = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|arm64.ActiveCfg = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|arm64.Build.0 = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|x64.ActiveCfg = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|x64.Build.0 = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|x86.ActiveCfg = Release|Any CPU + {A05652B3-953E-4915-9D7F-0E361D988815}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -11501,6 +11519,7 @@ Global {C406D9E0-1585-43F9-AA8F-D468AF84A996} = {60D51C98-2CC0-40DF-B338-44154EFEE2FF} {7757E360-40F5-4C90-9D7F-E6B0E62BA9E2} = {C406D9E0-1585-43F9-AA8F-D468AF84A996} {F0BF2260-5AE2-4248-81DE-AC5B9FC6A931} = {C406D9E0-1585-43F9-AA8F-D468AF84A996} + {A05652B3-953E-4915-9D7F-0E361D988815} = {0CE1CC26-98CE-4022-A81C-E32AAFC9B819} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Components/Components.slnf b/src/Components/Components.slnf index 28019dfe2494..67353d0e9aca 100644 --- a/src/Components/Components.slnf +++ b/src/Components/Components.slnf @@ -44,6 +44,7 @@ "src\\Components\\WebView\\WebView\\test\\Microsoft.AspNetCore.Components.WebView.Test.csproj", "src\\Components\\Web\\src\\Microsoft.AspNetCore.Components.Web.csproj", "src\\Components\\Web\\test\\Microsoft.AspNetCore.Components.Web.Tests.csproj", + "src\\Components\\benchmarkapps\\BlazingPizza.Server\\BlazingPizza.Server.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\Driver\\Wasm.Performance.Driver.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\TestApp\\Wasm.Performance.TestApp.csproj", "src\\Components\\test\\E2ETest\\Microsoft.AspNetCore.Components.E2ETests.csproj", diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj b/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj index 08d32e924989..0a92ed6f8863 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj +++ b/src/Components/benchmarkapps/BlazingPizza.Server/BlazingPizza.Server.csproj @@ -1,6 +1,17 @@  + $(DefaultNetCoreTargetFramework) true + $(NoWarn);IDE0161;IDE0073 + + + + + + + + + diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props b/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props deleted file mode 100644 index 8c119d5413b5..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.props +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets b/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets deleted file mode 100644 index 2e3fb2fa7134..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Directory.Build.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs b/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs index d17523aca123..6494cff9542c 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/JSRuntimeExtensions.cs @@ -1,13 +1,11 @@ -using Microsoft.JSInterop; -using System.Threading.Tasks; +using Microsoft.JSInterop; -namespace BlazingPizza.Server +namespace BlazingPizza.Server; + +public static class JSRuntimeExtensions { - public static class JSRuntimeExtensions + public static ValueTask Confirm(this IJSRuntime jsRuntime, string message) { - public static ValueTask Confirm(this IJSRuntime jsRuntime, string message) - { - return jsRuntime.InvokeAsync("confirm", message); - } + return jsRuntime.InvokeAsync("confirm", message); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs index d76bc52a8142..dfc8263f413e 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Address.cs @@ -1,27 +1,26 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +public class Address { - public class Address - { - public int Id { get; set; } + public int Id { get; set; } - [Required, MaxLength(100)] - public string Name { get; set; } + [Required, MaxLength(100)] + public string Name { get; set; } - [Required, MaxLength(100)] - public string Line1 { get; set; } + [Required, MaxLength(100)] + public string Line1 { get; set; } - [MaxLength(100)] - public string Line2 { get; set; } + [MaxLength(100)] + public string Line2 { get; set; } - [Required, MaxLength(50)] - public string City { get; set; } + [Required, MaxLength(50)] + public string City { get; set; } - [Required, MaxLength(20)] - public string Region { get; set; } + [Required, MaxLength(20)] + public string Region { get; set; } - [Required, MaxLength(20)] - public string PostalCode { get; set; } - } + [Required, MaxLength(20)] + public string PostalCode { get; set; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs index 9b8c38113973..23e281d28438 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/LatLong.cs @@ -1,27 +1,26 @@ -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +public class LatLong { - public class LatLong + public LatLong() { - public LatLong() - { - } + } - public LatLong(double latitude, double longitude) : this() - { - Latitude = latitude; - Longitude = longitude; - } + public LatLong(double latitude, double longitude) : this() + { + Latitude = latitude; + Longitude = longitude; + } - public double Latitude { get; set; } + public double Latitude { get; set; } - public double Longitude { get; set; } + public double Longitude { get; set; } - public static LatLong Interpolate(LatLong start, LatLong end, double proportion) - { - // The Earth is flat, right? So no need for spherical interpolation. - return new LatLong( - start.Latitude + (end.Latitude - start.Latitude) * proportion, - start.Longitude + (end.Longitude - start.Longitude) * proportion); - } + public static LatLong Interpolate(LatLong start, LatLong end, double proportion) + { + // The Earth is flat, right? So no need for spherical interpolation. + return new LatLong( + start.Latitude + (end.Latitude - start.Latitude) * proportion, + start.Longitude + (end.Longitude - start.Longitude) * proportion); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs index fb003bd6df07..3339187c35d2 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Order.cs @@ -1,25 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Globalization; -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +public class Order { - public class Order - { - public int OrderId { get; set; } + public int OrderId { get; set; } - public string UserId { get; set; } + public string UserId { get; set; } - public DateTime CreatedTime { get; set; } + public DateTime CreatedTime { get; set; } - public Address DeliveryAddress { get; set; } = new Address(); + public Address DeliveryAddress { get; set; } = new Address(); - public LatLong DeliveryLocation { get; set; } + public LatLong DeliveryLocation { get; set; } - public List Pizzas { get; set; } = new List(); + public List Pizzas { get; set; } = new List(); - public decimal GetTotalPrice() => Pizzas.Sum(p => p.GetTotalPrice()); + public decimal GetTotalPrice() => Pizzas.Sum(p => p.GetTotalPrice()); - public string GetFormattedTotalPrice() => GetTotalPrice().ToString("0.00"); - } + public string GetFormattedTotalPrice() => GetTotalPrice().ToString("0.00", CultureInfo.CurrentCulture); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs new file mode 100644 index 000000000000..f95dd052fe2f --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/OrderState.cs @@ -0,0 +1,64 @@ +namespace BlazingPizza.Server.Model; + +public class OrderState +{ + private readonly ILogger logger; + + public OrderState(ILogger logger) + { + this.logger = logger; + } + + public bool ShowingConfigureDialog { get; private set; } + + public Pizza ConfiguringPizza { get; private set; } + + public Order Order { get; private set; } = new Order(); + + public void ShowConfigurePizzaDialog(PizzaSpecial special) + { + logger.LogInformation($"Configuring pizza {special.Id}"); + + ConfiguringPizza = new Pizza() + { + Special = special, + SpecialId = special.Id, + Size = Pizza.DefaultSize, + Toppings = new List(), + }; + + ShowingConfigureDialog = true; + } + + public void CancelConfigurePizzaDialog() + { + ConfiguringPizza = null; + + ShowingConfigureDialog = false; + } + + public void ConfirmConfigurePizzaDialog() + { + logger.LogInformation($"Adding pizza {ConfiguringPizza.SpecialId}"); + + Order.Pizzas.Add(ConfiguringPizza); + ConfiguringPizza = null; + + ShowingConfigureDialog = false; + } + + public void RemoveConfiguredPizza(Pizza pizza) + { + Order.Pizzas.Remove(pizza); + } + + public void ResetOrder() + { + Order = new Order(); + } + + public void ReplaceOrder(Order order) + { + Order = order; + } +} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs index ec1108a98d1d..caba0152e955 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Pizza.cs @@ -1,42 +1,40 @@ -using System.Collections.Generic; -using System.Linq; +using System.Globalization; -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +/// +/// Represents a customized pizza as part of an order +/// +public class Pizza { - /// - /// Represents a customized pizza as part of an order - /// - public class Pizza - { - public const int DefaultSize = 12; - public const int MinimumSize = 9; - public const int MaximumSize = 17; + public const int DefaultSize = 12; + public const int MinimumSize = 9; + public const int MaximumSize = 17; - public int Id { get; set; } + public int Id { get; set; } - public int OrderId { get; set; } + public int OrderId { get; set; } - public PizzaSpecial Special { get; set; } + public PizzaSpecial Special { get; set; } - public int SpecialId { get; set; } + public int SpecialId { get; set; } - public int Size { get; set; } + public int Size { get; set; } - public List Toppings { get; set; } + public List Toppings { get; set; } - public decimal GetBasePrice() - { - return ((decimal)Size / (decimal)DefaultSize) * Special.BasePrice; - } + public decimal GetBasePrice() + { + return Special.BasePrice * (decimal)Size / DefaultSize; + } - public decimal GetTotalPrice() - { - return GetBasePrice() + Toppings.Sum(t => t.Topping.Price); - } + public decimal GetTotalPrice() + { + return GetBasePrice() + Toppings.Sum(t => t.Topping.Price); + } - public string GetFormattedTotalPrice() - { - return GetTotalPrice().ToString("0.00"); - } + public string GetFormattedTotalPrice() + { + return GetTotalPrice().ToString("0.00", CultureInfo.CurrentCulture); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs index d94b00be2dec..884ac27236e4 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaSpecial.cs @@ -1,20 +1,21 @@ -namespace BlazingPizza +using System.Globalization; + +namespace BlazingPizza.Server.Model; + +/// +/// Represents a pre-configured template for a pizza a user can order +/// +public class PizzaSpecial { - /// - /// Represents a pre-configured template for a pizza a user can order - /// - public class PizzaSpecial - { - public int Id { get; set; } + public int Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public int BasePrice { get; set; } + public int BasePrice { get; set; } - public string Description { get; set; } + public string Description { get; set; } - public string ImageUrl { get; set; } + public string ImageUrl { get; set; } - public string GetFormattedBasePrice() => BasePrice.ToString("0.00"); - } + public string GetFormattedBasePrice() => BasePrice.ToString("0.00", CultureInfo.CurrentCulture); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs index f5a6c1acdfa5..d8d861912cab 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/PizzaTopping.cs @@ -1,11 +1,10 @@ -namespace BlazingPizza +namespace BlazingPizza.Server.Model; + +public class PizzaTopping { - public class PizzaTopping - { - public Topping Topping { get; set; } + public Topping Topping { get; set; } - public int ToppingId { get; set; } - - public int PizzaId { get; set; } - } + public int ToppingId { get; set; } + + public int PizzaId { get; set; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs index 6c8a611ccbf9..5896d8b6737f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Point.cs @@ -1,9 +1,8 @@ -namespace BlazingPizza.Server +namespace BlazingPizza.Server.Model; + +public class Point { - public class Point - { - public double X { get; set; } + public double X { get; set; } - public double Y { get; set; } - } + public double Y { get; set; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs new file mode 100644 index 000000000000..d4c37cd1d33d --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/SpecialsService.cs @@ -0,0 +1,74 @@ +namespace BlazingPizza.Server.Model; + +public class SpecialsService +{ + public IList GetSpecials() + { + return new PizzaSpecial[] + { + new PizzaSpecial() + { + Name = "Basic Cheese Pizza", + Description = "It's cheesy and delicious. Why wouldn't you want one?", + BasePrice = 9, + ImageUrl = "img/pizzas/cheese.jpg", + }, + new PizzaSpecial() + { + Id = 2, + Name = "The Baconatorizor", + Description = "It has EVERY kind of bacon", + BasePrice = 12, + ImageUrl = "img/pizzas/bacon.jpg", + }, + new PizzaSpecial() + { + Id = 3, + Name = "Classic pepperoni", + Description = "It's the pizza you grew up with, but Blazing hot!", + BasePrice = 10, + ImageUrl = "img/pizzas/pepperoni.jpg", + }, + new PizzaSpecial() + { + Id = 4, + Name = "Buffalo chicken", + Description = "Spicy chicken, hot sauce and bleu cheese, guaranteed to warm you up", + BasePrice = 12, + ImageUrl = "img/pizzas/meaty.jpg", + }, + new PizzaSpecial() + { + Id = 5, + Name = "Mushroom Lovers", + Description = "It has mushrooms. Isn't that obvious?", + BasePrice = 11, + ImageUrl = "img/pizzas/mushroom.jpg", + }, + new PizzaSpecial() + { + Id = 6, + Name = "The Brit", + Description = "When in London...", + BasePrice = 10, + ImageUrl = "img/pizzas/brit.jpg", + }, + new PizzaSpecial() + { + Id = 7, + Name = "Veggie Delight", + Description = "It's like salad, but on a pizza", + BasePrice = 11, + ImageUrl = "img/pizzas/salad.jpg", + }, + new PizzaSpecial() + { + Id = 8, + Name = "Margherita", + Description = "Traditional Italian pizza with tomatoes and basil", + BasePrice = 9, + ImageUrl = "img/pizzas/margherita.jpg", + }, + }; + } +} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs index 61bdeb92000c..cbf90b3b88b7 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/Topping.cs @@ -1,13 +1,14 @@ -namespace BlazingPizza +using System.Globalization; + +namespace BlazingPizza.Server.Model; + +public class Topping { - public class Topping - { - public int Id { get; set; } + public int Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } - public decimal Price { get; set; } + public decimal Price { get; set; } - public string GetFormattedPrice() => Price.ToString("0.00"); - } + public string GetFormattedPrice() => Price.ToString("0.00", CultureInfo.CurrentCulture); } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs deleted file mode 100644 index 4996ef8042ae..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Model/UserInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BlazingPizza -{ - public class UserInfo - { - public bool IsAuthenticated { get; set; } - - public string Name { get; set; } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config b/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config deleted file mode 100644 index 2739120bf214..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs b/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs deleted file mode 100644 index 5e150303fc54..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/OrderState.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections.Generic; -using Microsoft.Extensions.Logging; - -namespace BlazingPizza.Server -{ - public class OrderState - { - private readonly ILogger logger; - - public OrderState(ILogger logger) - { - this.logger = logger; - } - - public bool ShowingConfigureDialog { get; private set; } - - public Pizza ConfiguringPizza { get; private set; } - - public Order Order { get; private set; } = new Order(); - - public void ShowConfigurePizzaDialog(PizzaSpecial special) - { - logger.LogInformation($"Configuring pizza {special.Id}"); - - ConfiguringPizza = new Pizza() - { - Special = special, - SpecialId = special.Id, - Size = Pizza.DefaultSize, - Toppings = new List(), - }; - - ShowingConfigureDialog = true; - } - - public void CancelConfigurePizzaDialog() - { - ConfiguringPizza = null; - - ShowingConfigureDialog = false; - } - - public void ConfirmConfigurePizzaDialog() - { - logger.LogInformation($"Adding pizza {ConfiguringPizza.SpecialId}"); - - Order.Pizzas.Add(ConfiguringPizza); - ConfiguringPizza = null; - - ShowingConfigureDialog = false; - } - - public void RemoveConfiguredPizza(Pizza pizza) - { - Order.Pizzas.Remove(pizza); - } - - public void ResetOrder() - { - Order = new Order(); - } - - public void ReplaceOrder(Order order) - { - Order = order; - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor index e41d5dd20474..ab1c71e3887f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Checkout.razor @@ -27,8 +27,6 @@ protected override void OnInitialized() { // Try to recover any temporary saved order - OrderState.ReplaceOrder(new Order - { - }); + OrderState.ReplaceOrder(new Order()); } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml index 07214adc9ed1..d25e64504f1b 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml @@ -1,22 +1,19 @@ @page "/" +@using BlazingPizza.Server +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - BlazorServerSIde + BlazingPizza.Server - - + + - @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered)) - - + + diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs index 02b01004147f..5ca83f31f635 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Program.cs @@ -1,23 +1,31 @@ -using System; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; +using BlazingPizza.Server; +using BlazingPizza.Server.Model; -namespace BlazingPizza.Server +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + app.UseExceptionHandler("/Error"); + app.UseHsts(); } + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json b/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json new file mode 100644 index 000000000000..91d7c0f2788d --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "BlazingPizza.Server": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:61128;http://localhost:61129" + } + } +} \ No newline at end of file diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs deleted file mode 100644 index 6e36dd222297..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/SpecialsService.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.Generic; - -namespace BlazingPizza.Server -{ - public class SpecialsService - { - public IList GetSpecials() - { - return new PizzaSpecial[] - { - new PizzaSpecial() - { - Name = "Basic Cheese Pizza", - Description = "It's cheesy and delicious. Why wouldn't you want one?", - BasePrice = 9, - ImageUrl = "img/pizzas/cheese.jpg", - }, - new PizzaSpecial() - { - Id = 2, - Name = "The Baconatorizor", - Description = "It has EVERY kind of bacon", - BasePrice = 12, - ImageUrl = "img/pizzas/bacon.jpg", - }, - new PizzaSpecial() - { - Id = 3, - Name = "Classic pepperoni", - Description = "It's the pizza you grew up with, but Blazing hot!", - BasePrice = 10, - ImageUrl = "img/pizzas/pepperoni.jpg", - }, - new PizzaSpecial() - { - Id = 4, - Name = "Buffalo chicken", - Description = "Spicy chicken, hot sauce and bleu cheese, guaranteed to warm you up", - BasePrice = 12, - ImageUrl = "img/pizzas/meaty.jpg", - }, - new PizzaSpecial() - { - Id = 5, - Name = "Mushroom Lovers", - Description = "It has mushrooms. Isn't that obvious?", - BasePrice = 11, - ImageUrl = "img/pizzas/mushroom.jpg", - }, - new PizzaSpecial() - { - Id = 6, - Name = "The Brit", - Description = "When in London...", - BasePrice = 10, - ImageUrl = "img/pizzas/brit.jpg", - }, - new PizzaSpecial() - { - Id = 7, - Name = "Veggie Delight", - Description = "It's like salad, but on a pizza", - BasePrice = 11, - ImageUrl = "img/pizzas/salad.jpg", - }, - new PizzaSpecial() - { - Id = 8, - Name = "Margherita", - Description = "Traditional Italian pizza with tomatoes and basil", - BasePrice = 9, - ImageUrl = "img/pizzas/margherita.jpg", - }, - }; - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs deleted file mode 100644 index 73fb78931ec9..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Startup.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.ResponseCompression; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System.Linq; -using System.Net.Mime; - -namespace BlazingPizza.Server -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - - services.AddServerSideBlazor(options => options.DetailedErrors = true); - - services.AddScoped(); - services.AddScoped(); - services.AddScoped(); - - services.AddResponseCompression(options => - { - options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( - new[] { MediaTypeNames.Application.Octet }); - }); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseResponseCompression(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapBlazorHub(); - endpoints.MapFallbackToPage("/_Host"); - }); - } - } -} diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs index 07c80c9790f4..ebce6b51a0ee 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs @@ -1,124 +1,123 @@ -using System.Collections.Generic; +using BlazingPizza.Server.Model; -namespace BlazingPizza.Server +namespace BlazingPizza.Server; + +public class ToppingsService { - public class ToppingsService + public IList GetToppings() { - public IList GetToppings() + return new Topping[] { - return new Topping[] - { - new Topping() - { - Name = "Extra cheese", - Price = 2.50m, - }, - new Topping() - { - Name = "American bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "British bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "Canadian bacon", - Price = 2.99m, - }, - new Topping() - { - Name = "Tea and crumpets", - Price = 5.00m - }, - new Topping() - { - Name = "Fresh-baked scones", - Price = 4.50m, - }, - new Topping() - { - Name = "Bell peppers", - Price = 1.00m, - }, - new Topping() - { - Name = "Onions", - Price = 1.00m, - }, - new Topping() - { - Name = "Mushrooms", - Price = 1.00m, - }, - new Topping() - { - Name = "Pepperoni", - Price = 1.00m, - }, - new Topping() - { - Name = "Duck sausage", - Price = 3.20m, - }, - new Topping() - { - Name = "Venison meatballs", - Price = 2.50m, - }, - new Topping() - { - Name = "Served on a silver platter", - Price = 250.99m, - }, - new Topping() - { - Name = "Lobster on top", - Price = 64.50m, - }, - new Topping() - { - Name = "Sturgeon caviar", - Price = 101.75m, - }, - new Topping() - { - Name = "Artichoke hearts", - Price = 3.40m, - }, - new Topping() - { - Name = "Fresh tomatoes", - Price = 1.50m, - }, - new Topping() - { - Name = "Basil", - Price = 1.50m, - }, - new Topping() - { - Name = "Steak (medium-rare)", - Price = 8.50m, - }, - new Topping() - { - Name = "Blazing hot peppers", - Price = 4.20m, - }, - new Topping() - { - Name = "Buffalo chicken", - Price = 5.00m, - }, - new Topping() - { - Name = "Blue cheese", - Price = 2.50m, - }, - }; - } + new Topping() + { + Name = "Extra cheese", + Price = 2.50m, + }, + new Topping() + { + Name = "American bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "British bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "Canadian bacon", + Price = 2.99m, + }, + new Topping() + { + Name = "Tea and crumpets", + Price = 5.00m + }, + new Topping() + { + Name = "Fresh-baked scones", + Price = 4.50m, + }, + new Topping() + { + Name = "Bell peppers", + Price = 1.00m, + }, + new Topping() + { + Name = "Onions", + Price = 1.00m, + }, + new Topping() + { + Name = "Mushrooms", + Price = 1.00m, + }, + new Topping() + { + Name = "Pepperoni", + Price = 1.00m, + }, + new Topping() + { + Name = "Duck sausage", + Price = 3.20m, + }, + new Topping() + { + Name = "Venison meatballs", + Price = 2.50m, + }, + new Topping() + { + Name = "Served on a silver platter", + Price = 250.99m, + }, + new Topping() + { + Name = "Lobster on top", + Price = 64.50m, + }, + new Topping() + { + Name = "Sturgeon caviar", + Price = 101.75m, + }, + new Topping() + { + Name = "Artichoke hearts", + Price = 3.40m, + }, + new Topping() + { + Name = "Fresh tomatoes", + Price = 1.50m, + }, + new Topping() + { + Name = "Basil", + Price = 1.50m, + }, + new Topping() + { + Name = "Steak (medium-rare)", + Price = 8.50m, + }, + new Topping() + { + Name = "Blazing hot peppers", + Price = 4.20m, + }, + new Topping() + { + Name = "Buffalo chicken", + Price = 5.00m, + }, + new Topping() + { + Name = "Blue cheese", + Price = 2.50m, + }, + }; } } diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor b/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor index f9e4f6730d74..32f6809bb2e4 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/_Imports.razor @@ -5,5 +5,6 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @using BlazingPizza.Server +@using BlazingPizza.Server.Model @using BlazingPizza.Server.Shared @using System.Security.Claims From 1360bf417297c567329d8e1b26f498186211a62b Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 10:19:05 +0000 Subject: [PATCH 2/8] Use PageTitle etc. --- .../benchmarkapps/BlazingPizza.Server/Pages/Index.razor | 2 ++ .../benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml | 3 ++- .../benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor index 36d14e6faa9e..8d24d73b3c3d 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/Index.razor @@ -3,6 +3,8 @@ @inject IJSRuntime JS @inject SpecialsService Specials +Blazing Pizza: Home +
    @if (specials != null) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml index d25e64504f1b..a5d41cd5a08e 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Pages/_Host.cshtml @@ -1,5 +1,6 @@ @page "/" @using BlazingPizza.Server +@using Microsoft.AspNetCore.Components.Web @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @@ -7,10 +8,10 @@ - BlazingPizza.Server + diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor b/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor index 8e4cc24cf8b8..158863a3a30f 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Shared/MainLayout.razor @@ -1,5 +1,7 @@ @inherits LayoutComponentBase +Blazing Pizza +
    From 3e780b04c3867f0ba7b2fccdd0d625563ce886b6 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 11:26:18 +0000 Subject: [PATCH 3/8] Add Crank instructions --- .../BlazingPizza.Server/README.md | 24 +++++++++++ .../BlazingPizza.Server/benchmarks.yml | 41 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/README.md create mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/README.md b/src/Components/benchmarkapps/BlazingPizza.Server/README.md new file mode 100644 index 000000000000..6fa225be873b --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/README.md @@ -0,0 +1,24 @@ +# Running the benchmark + +## To run the benchmark locally + +1. Install Crank *and* Crank Agent as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md +1. In a command prompt in any directory, start the agent by running `crank-agent`. Leave that running. +1. In a command prompt in this directory, build and this project via `dotnet build` and test it works using `dotnet run` +1. Now submit the crank job: + + crank --config benchmarks.yml --scenario hello --profile local + +## To run the job in the ASP.NET Core perf infrastructure (works for .NET team only) + +1. Install Crank as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md (no need for the agent) +1. In a command prompt in this directory, build and this project via `dotnet build` and test it works using `dotnet run` +1. Now submit the crank job: + + crank --config benchmarks.yml --scenario hello --profile aspnet-perf-win + +## Notes + +You may have to update the `runtimeVersion` in `benchmarks.yml`. Ideally it would be possible to specify `latest` there but that seems not to work currently. + +The benchmark uses the ASP.NET Core dlls you're building locally (it zips and uploads your files from `artifacts/bin/...`). It does not rebuild the entire repo on the Crank agent, as that would take too long for inner-loop. diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml new file mode 100644 index 000000000000..e12e9ce8beda --- /dev/null +++ b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml @@ -0,0 +1,41 @@ +imports: + - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml + +jobs: + server: + source: + localFolder: ../../../../artifacts/bin/BlazingPizza.Server/Debug/net8.0 + +scenarios: + hello: + application: + job: server + framework: net8.0 + runtimeVersion: 8.0.0-preview.2.23125.5 + executable: dotnet + arguments: BlazingPizza.Server.dll + load: + job: bombardier + variables: + serverPort: 5000 + path: / + +profiles: + local: + variables: + serverAddress: localhost + jobs: + application: + endpoints: + - http://localhost:5010 + load: + endpoints: + - http://localhost:5010 + aspnet-perf-win: + jobs: + application: + endpoints: + - http://asp-perf-win:5001 + load: + endpoints: + - http://asp-perf-db:5001 From dd8c2ac2dc4eb983d80f3ceb77d16b8c364122b6 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 11:30:08 +0000 Subject: [PATCH 4/8] Further Crank info --- .../BlazingPizza.Server/README.md | 4 +- .../BlazingPizza.Server/benchmarks.yml | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/README.md b/src/Components/benchmarkapps/BlazingPizza.Server/README.md index 6fa225be873b..c6a1364b99da 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/README.md +++ b/src/Components/benchmarkapps/BlazingPizza.Server/README.md @@ -13,9 +13,9 @@ 1. Install Crank as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md (no need for the agent) 1. In a command prompt in this directory, build and this project via `dotnet build` and test it works using `dotnet run` -1. Now submit the crank job: +1. Now submit the crank job. You can use `aspnet-perf-lin` or `aspnet-perf-win`, e.g.: - crank --config benchmarks.yml --scenario hello --profile aspnet-perf-win + crank --config benchmarks.yml --scenario hello --profile aspnet-perf-lin ## Notes diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml index e12e9ce8beda..91c13e79d502 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml @@ -31,11 +31,51 @@ profiles: load: endpoints: - http://localhost:5010 + aspnet-perf-lin: + variables: + serverAddress: 10.0.0.102 + cores: 12 + jobs: + db: + endpoints: + - http://asp-perf-db:5001 + aliases: + - downstream + - extra + application: + endpoints: + - http://asp-perf-lin:5001 + variables: + databaseServer: 10.0.0.103 + aliases: + - main + load: + endpoints: + - http://asp-perf-load:5001 + aliases: + - warmup + - secondary aspnet-perf-win: + variables: + serverAddress: 10.0.0.110 + cores: 12 jobs: + db: + endpoints: + - http://asp-perf-load:5001 + aliases: + - downstream + - extra application: endpoints: - http://asp-perf-win:5001 + variables: + databaseServer: 10.0.0.104 + aliases: + - main load: endpoints: - http://asp-perf-db:5001 + aliases: + - warmup + - secondary From 817d3b840cb208ab6f00fbccf8ea3c5df0aac480 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 12:16:05 +0000 Subject: [PATCH 5/8] Move file and fix namespace. Use release mode for benchmarks. --- .../BlazingPizza.Server/{ => Model}/ToppingsService.cs | 4 +--- src/Components/benchmarkapps/BlazingPizza.Server/README.md | 4 ++-- .../benchmarkapps/BlazingPizza.Server/benchmarks.yml | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) rename src/Components/benchmarkapps/BlazingPizza.Server/{ => Model}/ToppingsService.cs (97%) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs b/src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs similarity index 97% rename from src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs rename to src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs index ebce6b51a0ee..1ba0f8989e1c 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/ToppingsService.cs +++ b/src/Components/benchmarkapps/BlazingPizza.Server/Model/ToppingsService.cs @@ -1,6 +1,4 @@ -using BlazingPizza.Server.Model; - -namespace BlazingPizza.Server; +namespace BlazingPizza.Server.Model; public class ToppingsService { diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/README.md b/src/Components/benchmarkapps/BlazingPizza.Server/README.md index c6a1364b99da..b19aa5cc98d4 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/README.md +++ b/src/Components/benchmarkapps/BlazingPizza.Server/README.md @@ -4,7 +4,7 @@ 1. Install Crank *and* Crank Agent as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md 1. In a command prompt in any directory, start the agent by running `crank-agent`. Leave that running. -1. In a command prompt in this directory, build and this project via `dotnet build` and test it works using `dotnet run` +1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` 1. Now submit the crank job: crank --config benchmarks.yml --scenario hello --profile local @@ -12,7 +12,7 @@ ## To run the job in the ASP.NET Core perf infrastructure (works for .NET team only) 1. Install Crank as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md (no need for the agent) -1. In a command prompt in this directory, build and this project via `dotnet build` and test it works using `dotnet run` +1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` 1. Now submit the crank job. You can use `aspnet-perf-lin` or `aspnet-perf-win`, e.g.: crank --config benchmarks.yml --scenario hello --profile aspnet-perf-lin diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml index 91c13e79d502..066b16198ed0 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml @@ -4,7 +4,7 @@ imports: jobs: server: source: - localFolder: ../../../../artifacts/bin/BlazingPizza.Server/Debug/net8.0 + localFolder: ../../../../artifacts/bin/BlazingPizza.Server/Release/net8.0 scenarios: hello: From 810e363eb3aae25e9f05f951103a835aa2e87533 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 1 Mar 2023 12:31:52 +0000 Subject: [PATCH 6/8] Clarifications --- src/Components/benchmarkapps/BlazingPizza.Server/README.md | 6 +++--- .../{benchmarks.yml => ssr-benchmarks.yml} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/Components/benchmarkapps/BlazingPizza.Server/{benchmarks.yml => ssr-benchmarks.yml} (99%) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/README.md b/src/Components/benchmarkapps/BlazingPizza.Server/README.md index b19aa5cc98d4..bebb8f888114 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/README.md +++ b/src/Components/benchmarkapps/BlazingPizza.Server/README.md @@ -1,4 +1,4 @@ -# Running the benchmark +# Running the SSR benchmark ## To run the benchmark locally @@ -7,7 +7,7 @@ 1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` 1. Now submit the crank job: - crank --config benchmarks.yml --scenario hello --profile local + crank --config ssr-benchmarks.yml --scenario ssr --profile local ## To run the job in the ASP.NET Core perf infrastructure (works for .NET team only) @@ -15,7 +15,7 @@ 1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` 1. Now submit the crank job. You can use `aspnet-perf-lin` or `aspnet-perf-win`, e.g.: - crank --config benchmarks.yml --scenario hello --profile aspnet-perf-lin + crank --config ssr-benchmarks.yml --scenario ssr --profile aspnet-perf-lin ## Notes diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml similarity index 99% rename from src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml rename to src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml index 066b16198ed0..0ef6cefd2367 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/benchmarks.yml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml @@ -7,7 +7,7 @@ jobs: localFolder: ../../../../artifacts/bin/BlazingPizza.Server/Release/net8.0 scenarios: - hello: + ssr: application: job: server framework: net8.0 From acb80cfe371f9b63ec9b48c3083689e0aaf58c50 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 2 Mar 2023 16:23:32 +0000 Subject: [PATCH 7/8] Import profiles --- .../BlazingPizza.Server/ssr-benchmarks.yml | 63 +------------------ 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml index 0ef6cefd2367..b378b525acbf 100644 --- a/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml +++ b/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml @@ -1,5 +1,6 @@ imports: - - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml + - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml + - https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/aspnet.profiles.standard.yml jobs: server: @@ -19,63 +20,3 @@ scenarios: variables: serverPort: 5000 path: / - -profiles: - local: - variables: - serverAddress: localhost - jobs: - application: - endpoints: - - http://localhost:5010 - load: - endpoints: - - http://localhost:5010 - aspnet-perf-lin: - variables: - serverAddress: 10.0.0.102 - cores: 12 - jobs: - db: - endpoints: - - http://asp-perf-db:5001 - aliases: - - downstream - - extra - application: - endpoints: - - http://asp-perf-lin:5001 - variables: - databaseServer: 10.0.0.103 - aliases: - - main - load: - endpoints: - - http://asp-perf-load:5001 - aliases: - - warmup - - secondary - aspnet-perf-win: - variables: - serverAddress: 10.0.0.110 - cores: 12 - jobs: - db: - endpoints: - - http://asp-perf-load:5001 - aliases: - - downstream - - extra - application: - endpoints: - - http://asp-perf-win:5001 - variables: - databaseServer: 10.0.0.104 - aliases: - - main - load: - endpoints: - - http://asp-perf-db:5001 - aliases: - - warmup - - secondary From fcbfb7c1acd74dfe132389bd18ae03ae7af131b9 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 7 Mar 2023 14:21:53 +0000 Subject: [PATCH 8/8] Remove Crank files as they are now in benchmarks repo --- .../BlazingPizza.Server/README.md | 24 ------------------- .../BlazingPizza.Server/ssr-benchmarks.yml | 22 ----------------- 2 files changed, 46 deletions(-) delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/README.md delete mode 100644 src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/README.md b/src/Components/benchmarkapps/BlazingPizza.Server/README.md deleted file mode 100644 index bebb8f888114..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Running the SSR benchmark - -## To run the benchmark locally - -1. Install Crank *and* Crank Agent as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md -1. In a command prompt in any directory, start the agent by running `crank-agent`. Leave that running. -1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` -1. Now submit the crank job: - - crank --config ssr-benchmarks.yml --scenario ssr --profile local - -## To run the job in the ASP.NET Core perf infrastructure (works for .NET team only) - -1. Install Crank as per instructions at https://github.com/dotnet/crank/blob/main/docs/getting_started.md (no need for the agent) -1. In a command prompt in this directory, build and this project via `dotnet build -c Release` and optionally test it works using `dotnet run -c Release` -1. Now submit the crank job. You can use `aspnet-perf-lin` or `aspnet-perf-win`, e.g.: - - crank --config ssr-benchmarks.yml --scenario ssr --profile aspnet-perf-lin - -## Notes - -You may have to update the `runtimeVersion` in `benchmarks.yml`. Ideally it would be possible to specify `latest` there but that seems not to work currently. - -The benchmark uses the ASP.NET Core dlls you're building locally (it zips and uploads your files from `artifacts/bin/...`). It does not rebuild the entire repo on the Crank agent, as that would take too long for inner-loop. diff --git a/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml b/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml deleted file mode 100644 index b378b525acbf..000000000000 --- a/src/Components/benchmarkapps/BlazingPizza.Server/ssr-benchmarks.yml +++ /dev/null @@ -1,22 +0,0 @@ -imports: - - https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml - - https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/aspnet.profiles.standard.yml - -jobs: - server: - source: - localFolder: ../../../../artifacts/bin/BlazingPizza.Server/Release/net8.0 - -scenarios: - ssr: - application: - job: server - framework: net8.0 - runtimeVersion: 8.0.0-preview.2.23125.5 - executable: dotnet - arguments: BlazingPizza.Server.dll - load: - job: bombardier - variables: - serverPort: 5000 - path: /