Add RazorRendering benchmarkapp (#8366)
* Add RazorRendering benchmarkapp
This commit is contained in:
parent
bca3160190
commit
b48b282ad8
17
Mvc.sln
17
Mvc.sln
|
|
@ -178,7 +178,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicViews", "benchmarkapps
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mvc.Api.Analyzers.Test", "test\Mvc.Api.Analyzers.Test\Mvc.Api.Analyzers.Test.csproj", "{DD7B9F20-354C-4D9E-8C8A-8AE6E7595A87}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Mvc.Api.Analyzers", "src\Microsoft.AspNetCore.Mvc.Api.Analyzers\Microsoft.AspNetCore.Mvc.Api.Analyzers.csproj", "{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Api.Analyzers", "src\Microsoft.AspNetCore.Mvc.Api.Analyzers\Microsoft.AspNetCore.Mvc.Api.Analyzers.csproj", "{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorRendering", "benchmarkapps\RazorRendering\RazorRendering.csproj", "{D7C6A696-F232-4288-BCCD-367407E4A934}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -952,6 +954,18 @@ Global
|
|||
{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA}.Release|x86.Build.0 = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -1025,6 +1039,7 @@ Global
|
|||
{E89EB74D-C1CE-456F-B42D-CCF1575E0CFB} = {2859F266-673A-45A2-9E3C-7B39C6DDD38E}
|
||||
{DD7B9F20-354C-4D9E-8C8A-8AE6E7595A87} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{3B550487-10E4-4E6D-9CEF-B1B4CA1253DA} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{D7C6A696-F232-4288-BCCD-367407E4A934} = {2859F266-673A-45A2-9E3C-7B39C6DDD38E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {63D344F6-F86D-40E6-85B9-0AABBE338C4A}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
using Microsoft.AspNetCore.Html;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class DataA
|
||||
{
|
||||
public DataA(int id, HtmlString icon, HtmlString html, string name, int seconds, int max, float perHour)
|
||||
{
|
||||
Id = id;
|
||||
Icon = icon;
|
||||
Html = html;
|
||||
Name = name;
|
||||
Seconds = seconds;
|
||||
Max = max;
|
||||
PerHour = perHour;
|
||||
}
|
||||
|
||||
public int Id { get; }
|
||||
public HtmlString Icon { get; }
|
||||
public HtmlString Html { get; }
|
||||
public string Name { get; }
|
||||
public int Seconds { get; }
|
||||
public int Max { get; }
|
||||
public float PerHour { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class DataB
|
||||
{
|
||||
public DataB(int id, HtmlString icon, string name, int value, DateTimeOffset startDate, DateTimeOffset completeDate)
|
||||
{
|
||||
Id = id;
|
||||
Icon = icon;
|
||||
Name = name;
|
||||
Value = value;
|
||||
StartDate = startDate;
|
||||
CompleteDate = completeDate;
|
||||
}
|
||||
|
||||
public int Id { get; }
|
||||
public HtmlString Icon { get; }
|
||||
public string Name { get; }
|
||||
public int Value { get; }
|
||||
public DateTimeOffset StartDate { get; }
|
||||
public DateTimeOffset CompleteDate { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
@page
|
||||
@model Pages.PageA
|
||||
@using static System.Convert
|
||||
|
||||
@section Subcategories {
|
||||
<partial name="_Subcategories" />
|
||||
}
|
||||
|
||||
@section Tabs {
|
||||
<span class="dialog-tab@(Model.Condition ? " selected" : "")"><span class="link" data-url="/Category/PageA">Sub cat A</span></span>
|
||||
<span class="dialog-tab"><span class="link" data-url="/Category/PageB/@Model.Value1/@Model.Value2">Sub cat B</span></span>
|
||||
<span class="dialog-tab"><span class="link" data-url="/Category/PageC/@((int)Model.Value3)">Sub cat C</span></span>
|
||||
<span class="dialog-tab@(!Model.Condition ? " selected" : "")"><span class="link" data-url="/Category/PageD/@((int)Model.Value3)">Sub cat D</span></span>
|
||||
}
|
||||
|
||||
@switch (Model.Value)
|
||||
{
|
||||
case 0:
|
||||
<h1>@Model.Name Type A</h1>
|
||||
break;
|
||||
case 1:
|
||||
<h1>@Model.Name Type B</h1>
|
||||
break;
|
||||
case 2:
|
||||
<h1>@Model.Name Type C</h1>
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
<h3 style="clear:both;">Something Something</h3>
|
||||
<div>
|
||||
<table class="generic small oddeven middle center">
|
||||
<tr>
|
||||
<th style="width: 24px;"></th>
|
||||
<th>Something</th>
|
||||
<th style="width: 270px;">Something Something</th>
|
||||
@if (Model.Value3 != 0)
|
||||
{
|
||||
<th style="width: 70px;" class="dull right">Something</th>
|
||||
}
|
||||
<th style="width: 130px;"></th>
|
||||
</tr>
|
||||
@{
|
||||
foreach (var data in Model.Data1)
|
||||
{
|
||||
<tr>
|
||||
<td class="left">@data.Icon</td>
|
||||
<td class="left">@data.Name</td>
|
||||
<td style="text-align:center">@data.Html</td>
|
||||
@if (Model.Value3 != 0)
|
||||
{
|
||||
<td class="dull right">
|
||||
@(new TimeSpan(0, 0, (int)data.Seconds)) <br />
|
||||
(@data.PerHour.ToString("N2") p/h)
|
||||
</td>
|
||||
}
|
||||
<td>
|
||||
<form asp-page-handler="Make">
|
||||
<input type="hidden" name="Id" value="@((int)Model.Value3)" />
|
||||
<input type="hidden" name="ResType" value="@data.Id" />
|
||||
<input type="text" name="Quantity" style="width: 35px; font-size: 11px; text-align: left;" placeholder="@data.Max.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)" />
|
||||
<a href="#" class="max">max</a>
|
||||
<button class="small">Make</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3 style="clear:both;">Something something something</h3>
|
||||
<div>
|
||||
@{
|
||||
if (Model.Data2.Count > 0)
|
||||
{
|
||||
<table class="oddeven" style="font-size: 11px;">
|
||||
<tr>
|
||||
<th style="width:20px"></th>
|
||||
<th class="left">SomethingA</th>
|
||||
<th style="width: 80px;">SomethingB</th>
|
||||
<th style="width: 60px">SomethingC</th>
|
||||
<th>SomethingD</th>
|
||||
<th style="width: 60px">SomethingE</th>
|
||||
<th style="width: 90px;">SomethingF</th>
|
||||
<th style="width: 56px;"></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var data in Model.Data2)
|
||||
{
|
||||
var StartDate = data.StartDate;
|
||||
var CompleteDate = data.CompleteDate;
|
||||
|
||||
<tr>
|
||||
<td>@data.Icon</td>
|
||||
<td class="left">@data.Name</td>
|
||||
<td>@data.Value</td>
|
||||
<td class="center">@StartDate.ToString("dd MMM HH:mm:ss")</td>
|
||||
@{
|
||||
float percentage = 100f;
|
||||
|
||||
var totalTime = CompleteDate.Subtract(StartDate).TotalMilliseconds;
|
||||
if (totalTime > 1000)
|
||||
{
|
||||
percentage = 100f * (float)DateTimeOffset.UtcNow.Subtract(StartDate).TotalMilliseconds / (float)totalTime;
|
||||
}
|
||||
|
||||
percentage = MathF.Min(100f, MathF.Max(0f, percentage));
|
||||
|
||||
var startDate = ToInt64(StartDate.Subtract(DateTime.UnixEpoch).Ticks / (double)10000);
|
||||
var endDate = ToInt64(CompleteDate.Subtract(DateTime.UnixEpoch).Ticks / (double)10000);
|
||||
}
|
||||
<td>
|
||||
<div class="progBar">
|
||||
<div class="progProgress" data-start="@startDate" data-end="@endDate" style="width: @(percentage.ToString("N0"))%;"></div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="center">@CompleteDate.ToString("dd MMM HH:mm:ss")</td>
|
||||
<td>
|
||||
<span class="progTime" data-start="@startDate" data-end="@endDate">@(CompleteDate.Subtract(DateTime.UtcNow).ToString())</span>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" asp-page-handler="Cancel">
|
||||
<input type="hidden" name="id" value="@data.Id" />
|
||||
<button class="small">Cancel</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Something @Model.Name something something something something.</span>
|
||||
}
|
||||
|
||||
}
|
||||
</div>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using Data;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pages
|
||||
{
|
||||
public class PageA : Page
|
||||
{
|
||||
public int Value { get; } = 0;
|
||||
public int Value1 { get; } = 0;
|
||||
public int Value2 { get; } = 0;
|
||||
public int Value3 { get; } = 1;
|
||||
public bool Condition { get; } = true;
|
||||
|
||||
public string Name { get; } = "A Name";
|
||||
|
||||
public List<DataA> Data1 { get; }
|
||||
public List<DataB> Data2 { get; }
|
||||
|
||||
public PageA(List<DataA> dataA, List<DataB> dataB, ILogger<PageA> logger) : base(logger)
|
||||
{
|
||||
Data1 = dataA;
|
||||
Data2 = dataB;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
PageTitle = "PageA Title";
|
||||
PageIcon = "sicon dialogue_pagea";
|
||||
await Task.Delay(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
@model Pages.Page
|
||||
|
||||
<div class="dialog-subcat">
|
||||
<div data-url="/Category/PageA" title="PageA Title" class="sicon dialogue_pagea"></div>
|
||||
<div data-url="/Category/PageB" title="PageB Title" class="sicon dialogue_pageb"></div>
|
||||
<div data-url="/Category/PageC" title="PageC Title" class="sicon dialogue_pagec"></div>
|
||||
<div data-url="/Category/PageD" title="PageD Title" class="sicon dialogue_paged"></div>
|
||||
<div data-url="/Category/PageE" title="PageE Title" class="sicon dialogue_pagee"></div>
|
||||
<div data-url="/Category/PageF" title="PageF Title" class="sicon dialogue_pagef"></div>
|
||||
<div data-url="/Category/PageG" title="PageG Title" class="sicon dialogue_pageg"></div>
|
||||
</div>
|
||||
<div class="licon micon dialogue_category"></div>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
using System.Text.Encodings.Web;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Pages
|
||||
{
|
||||
public class Page : PageModel
|
||||
{
|
||||
public ILogger Logger { get; }
|
||||
|
||||
public string PageIcon { get; protected set; }
|
||||
public string PageTitle { get; protected set; }
|
||||
public string PageUrl { get; protected set; }
|
||||
|
||||
public Page(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public void AddErrorMessage(string message)
|
||||
{
|
||||
Response.Headers.Add("X-Error-Message", UrlEncoder.Default.Encode(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
@model Pages.Page
|
||||
|
||||
@RenderSection("Subcategories")
|
||||
<div class="dialog-title-icon @Model.PageIcon"></div>
|
||||
<div class="dialog-title">@Model.PageTitle</div>
|
||||
@{
|
||||
var hasTabs = IsSectionDefined("Tabs");
|
||||
}
|
||||
<div class="dialog-body@(hasTabs ? "-tabs" : "")">
|
||||
@if (hasTabs)
|
||||
{
|
||||
<div class="dialog-tabs">
|
||||
@RenderSection("Tabs", required: false)
|
||||
</div>
|
||||
}
|
||||
<div class="dialog-parch-bottom@(hasTabs ? " tabs" : "")">
|
||||
<div id="contentScroll" tabindex="20" class="dialog-parch-scroll@(hasTabs ? " tabs" : "")">
|
||||
<div class="dialog-parch-left">
|
||||
<div class="dialog-parch-right">
|
||||
<div id="contentWindow" class="dialog-parch@(hasTabs ? " tabs" : "")">
|
||||
@RenderBody()
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-parch-shadow@(hasTabs ? " tabs" : "")"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-close-icon icon_close"></div>
|
||||
<div class="dialog-bottom-left-edge"></div>
|
||||
<div class="dialog-bottom-edge"></div>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- These references are used when running locally -->
|
||||
<ItemGroup Condition="'$(BenchmarksTargetFramework)' == ''">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" />
|
||||
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
These references are used when running on the Benchmarks Server.
|
||||
-->
|
||||
<ItemGroup Condition="'$(BenchmarksTargetFramework)' != ''">
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="$(MicrosoftNETCoreApp22PackageVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1 @@
|
|||
Url: /Category/PageA
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.IO;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<List<DataA>>(_ => DataA);
|
||||
services.AddScoped<List<DataB>>(_ => DataB);
|
||||
services.AddMvc()
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
private static List<DataA> DataA = GenerateDataA();
|
||||
|
||||
private static List<DataA> GenerateDataA()
|
||||
{
|
||||
var dataA = new List<DataA>();
|
||||
|
||||
foreach (var i in Enumerable.Range(0, 100))
|
||||
{
|
||||
dataA.Add(new DataA(i, new HtmlString(i.ToString()), new HtmlString(i.ToString()), i.ToString(), i, i, 60f / i));
|
||||
}
|
||||
|
||||
return dataA;
|
||||
}
|
||||
|
||||
private static List<DataB> DataB = GenerateDataB();
|
||||
|
||||
private static List<DataB> GenerateDataB()
|
||||
{
|
||||
var utc = DateTimeOffset.UtcNow;
|
||||
var dataB = new List<DataB>();
|
||||
foreach (var i in Enumerable.Range(0, 100))
|
||||
{
|
||||
dataB.Add(new DataB(i, new HtmlString(i.ToString()), i.ToString(), i, utc, utc));
|
||||
}
|
||||
|
||||
return dataB;
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = CreateWebHostBuilder(args)
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddEnvironmentVariables()
|
||||
.AddCommandLine(args)
|
||||
.Build();
|
||||
|
||||
return new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseUrls("http://+:5000")
|
||||
.UseConfiguration(configuration)
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue