Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -0,0 +1 @@
<Router AppAssembly=typeof(Program).Assembly />

View File

@@ -0,0 +1,17 @@
// 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 Microsoft.JSInterop;
namespace Microsoft.AspNetCore.Blazor.E2EPerformance
{
public static class BenchmarkEvent
{
public static void Send(IJSRuntime jsRuntime, string name)
{
((IJSInProcessRuntime)jsRuntime).Invoke<object>(
"receiveBenchmarkEvent",
name);
}
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ReferenceBlazorBuildLocally>true</ReferenceBlazorBuildLocally>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Blazor" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,11 @@
@page "/"
@inject IJSRuntime JSRuntime
Hello, world!
@functions {
protected override void OnAfterRender()
{
BenchmarkEvent.Send(JSRuntime, "Rendered index.cshtml");
}
}

View File

@@ -0,0 +1,98 @@
@page "/json"
@inject IJSRuntime JSRuntime
<h2>JSON performance</h2>
<p><button id="reset-all" onclick=@Reset>Reset</button></p>
<button id="serialize-small" onclick=@SerializeSmall>Serialize (small)</button>
<button id="serialize-large" onclick=@SerializeLarge>Serialize (large)</button>
<p><pre style="border: 1px solid black; overflow: scroll;">@serializedValue</pre></p>
@if (serializedValue != null)
{
<p>Serialized length: <strong id="serialized-length">@serializedValue.Length</strong> chars</p>
}
<button id="deserialize-small" onclick=@DeserializeSmall>Deserialize (small)</button>
<button id="deserialize-large" onclick=@DeserializeLarge>Deserialize (large)</button>
@if (numPeopleDeserialized > 0)
{
<p>Deserialized <strong id="deserialized-count">@numPeopleDeserialized</strong> people</p>
}
@functions {
static string[] Clearances = new[] { "Alpha", "Beta", "Gamma", "Delta", "Epsilon" };
Person smallOrgChart = GenerateOrgChart(1, 4);
Person largeOrgChart = GenerateOrgChart(5, 4);
string smallOrgChartJson;
string largeOrgChartJson;
int numPeopleDeserialized;
protected override void OnInit()
{
smallOrgChartJson = Microsoft.JSInterop.Json.Serialize(smallOrgChart);
largeOrgChartJson = Microsoft.JSInterop.Json.Serialize(largeOrgChart);
}
protected override void OnAfterRender()
{
BenchmarkEvent.Send(JSRuntime, "Finished JSON processing");
}
string serializedValue;
void Reset()
{
serializedValue = null;
numPeopleDeserialized = 0;
}
void SerializeSmall()
=> serializedValue = Microsoft.JSInterop.Json.Serialize(smallOrgChart);
void SerializeLarge()
=> serializedValue = Microsoft.JSInterop.Json.Serialize(largeOrgChart);
void DeserializeSmall()
=> numPeopleDeserialized = Deserialize(smallOrgChartJson);
void DeserializeLarge()
=> numPeopleDeserialized = Deserialize(largeOrgChartJson);
static Person GenerateOrgChart(int totalDepth, int numDescendantsPerNode, int thisDepth = 0, string namePrefix = null, int siblingIndex = 0)
{
var name = $"{namePrefix ?? "CEO"} - Subordinate {siblingIndex}";
var rng = new Random(0);
return new Person
{
Name = name,
IsAdmin = siblingIndex % 2 == 0,
Salary = 10000000 / (thisDepth + 1),
SecurityClearances = Clearances
.ToDictionary(c => c, _ => (object)(rng.Next(0, 2) == 0)),
Subordinates = Enumerable.Range(0, thisDepth < totalDepth ? numDescendantsPerNode : 0)
.Select(index => GenerateOrgChart(totalDepth, numDescendantsPerNode, thisDepth + 1, name, index))
.ToList()
};
}
static int Deserialize(string json)
{
var ceo = Microsoft.JSInterop.Json.Deserialize<Person>(json);
return CountPeople(ceo);
}
static int CountPeople(Person root)
=> 1 + (root.Subordinates?.Sum(CountPeople) ?? 0);
class Person
{
public string Name { get; set; }
public int Salary { get; set; }
public bool IsAdmin { get; set; }
public List<Person> Subordinates { get; set; }
public Dictionary<string, object> SecurityClearances { get; set; }
}
}

View File

@@ -0,0 +1,75 @@
@page "/renderlist"
@inject IJSRuntime JSRuntime
<h2>Render List</h2>
Number of items: <input id="num-items" type="number" bind=@numItems />
<button id="show-list" onclick=@Show>Show</button>
<button id="hide-list" onclick=@Hide>Hide</button>
@if (show)
{
<table class='table'>
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in GenerateForecasts(numItems))
{
<tr>
<td>@forecast.DateFormatted</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@functions {
int numItems = 10;
bool show = false;
void Hide()
{
show = false;
}
void Show()
{
show = true;
}
protected override void OnAfterRender()
{
BenchmarkEvent.Send(JSRuntime, "Finished rendering list");
}
static IEnumerable<WeatherForecast> GenerateForecasts(int count)
{
for (var i = 0; i < count; i++)
{
yield return new WeatherForecast
{
DateFormatted = DateTime.Now.AddDays(i).ToShortDateString(),
TemperatureC = i % 100,
TemperatureF = (int)((i % 100) * 1.8) + 32,
Summary = $"Item {i}",
};
}
}
class WeatherForecast
{
public string DateFormatted { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF { get; set; }
public string Summary { get; set; }
}
}

View File

@@ -0,0 +1 @@
@layout MainLayout

View File

@@ -0,0 +1,19 @@
// 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 Microsoft.AspNetCore.Blazor.Hosting;
namespace Microsoft.AspNetCore.Blazor.E2EPerformance
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
}
}

View File

@@ -0,0 +1,13 @@
@inherits LayoutComponentBase
<h1>E2E Performance</h1>
<a href="">Home</a> |
<a href="renderlist">RenderList</a> |
<a href="json">JSON</a>
<hr/>
<div>
@Body
</div>

View File

@@ -0,0 +1,20 @@
// 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 Microsoft.AspNetCore.Components.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Blazor.E2EPerformance
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("app");
}
}
}

View File

@@ -0,0 +1,6 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Layouts
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.JSInterop
@using Microsoft.AspNetCore.Blazor.E2EPerformance
@using Microsoft.AspNetCore.Blazor.E2EPerformance.Shared

View File

@@ -0,0 +1,68 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Microsoft.AspNetCore.Components.Browser</name>
</assembly>
<members>
<member name="T:Microsoft.AspNetCore.Components.Browser.RendererRegistry">
<summary>
Framework infrastructure, not intended to be used by application code.
</summary>
</member>
<member name="P:Microsoft.AspNetCore.Components.Browser.RendererRegistry.Current">
<summary>
Framework infrastructure, not intended to be used by application code.
</summary>
</member>
<member name="M:Microsoft.AspNetCore.Components.Browser.RendererRegistry.SetCurrentRendererRegistry(Microsoft.AspNetCore.Components.Browser.RendererRegistry)">
<summary>
Framework infrastructure, not intended by used by application code.
</summary>
</member>
<member name="M:Microsoft.AspNetCore.Components.Browser.RendererRegistry.Add(Microsoft.AspNetCore.Components.Rendering.Renderer)">
<summary>
Framework infrastructure, not intended by used by application code.
</summary>
</member>
<member name="M:Microsoft.AspNetCore.Components.Browser.RendererRegistry.Find(System.Int32)">
<summary>
Framework infrastructure, not intended by used by application code.
</summary>
</member>
<member name="M:Microsoft.AspNetCore.Components.Browser.RendererRegistry.TryRemove(System.Int32)">
<summary>
Framework infrastructure, not intended by used by application code.
</summary>
</member>
<member name="T:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher">
<summary>
Provides mechanisms for dispatching events to components in a <see cref="T:Microsoft.AspNetCore.Components.Rendering.Renderer"/>.
</summary>
</member>
<member name="M:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.DispatchEvent(Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.BrowserEventDescriptor,System.String)">
<summary>
For framework use only.
</summary>
</member>
<member name="T:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.BrowserEventDescriptor">
<summary>
For framework use only.
</summary>
</member>
<member name="P:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.BrowserEventDescriptor.BrowserRendererId">
<summary>
For framework use only.
</summary>
</member>
<member name="P:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.BrowserEventDescriptor.EventHandlerId">
<summary>
For framework use only.
</summary>
</member>
<member name="P:Microsoft.AspNetCore.Components.Browser.RendererRegistryEventDispatcher.BrowserEventDescriptor.EventArgsType">
<summary>
For framework use only.
</summary>
</member>
</members>
</doc>

Some files were not shown because too many files have changed in this diff Show More