Skip to content

Commit

Permalink
Add repro for dotnet/runtime#48179
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Feb 11, 2021
1 parent 82523e4 commit 954148d
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Bug48179/Bug48179.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30709.64
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bug48179", "Bug48179\Bug48179.csproj", "{ECBFC915-4001-4ABF-AE41-494BF20BA639}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ECBFC915-4001-4ABF-AE41-494BF20BA639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECBFC915-4001-4ABF-AE41-494BF20BA639}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECBFC915-4001-4ABF-AE41-494BF20BA639}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECBFC915-4001-4ABF-AE41-494BF20BA639}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A5ADCCFE-043A-4C65-921C-AA5496CF24AB}
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions Bug48179/Bug48179/Bug48179.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<!--<WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile>-->
<WasmShellMonoRuntimeExecutionMode>FullAOT</WasmShellMonoRuntimeExecutionMode>
<!--<WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode>-->
<WasmShellEnableEmccProfiling>true</WasmShellEnableEmccProfiling>
<!--<WasmShellDisableSDKCheckSumValidation>true</WasmShellDisableSDKCheckSumValidation>-->
<WasmShellEnableNetCoreICU>false</WasmShellEnableNetCoreICU>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup Condition="'$(WasmShellMonoRuntimeExecutionMode)'=='InterpreterAndAOT'">
<WasmShellEnableAotProfile Include="aot.profile" />
</ItemGroup>

<ItemGroup>
<LinkerDescriptor Include="Linker.xml" />
</ItemGroup>

<!--
<ItemGroup>
<WasmShellExtraEmccFlags Include="-fsanitize=address" />
<WasmShellExtraEmccFlags Include="-s TOTAL_MEMORY=393216000" />
</ItemGroup>
-->

<ItemGroup>
<PackageReference Include="Uno.Wasm.Bootstrap" Version="2.0.0-dev.163" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.0.0-dev.163" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Bug48179/Bug48179/Linker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<linker>
<assembly fullname="Bug48163"/>
</linker>
84 changes: 84 additions & 0 deletions Bug48179/Bug48179/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;

static class Program
{
// const int outerCount = 1;
const int innerCount = 1;
const int maxDepth = 4;

static void Main(string[] args)
{
NestedLoopPerf_ForLoop();
NestedLoopPerf_ForEachLoop();
}

private static void NestedLoopPerf_ForLoop()
{
var list = Enumerable.Range(0, 10).ToList();

var r1 = Stopwatch.StartNew();
Bench(list);
r1.Stop();

Console.WriteLine($"r1={r1.Elapsed}");

static void Bench(List<int> array)
{
for (int i = 0; i < innerCount; i++)
{
Nest(0);
}

void Nest(int depth)
{
if(depth == maxDepth)
{
return;
}

for (int i = 0; i < array.Count; i++)
{
Nest(depth + 1);
}
}
}
}

private static void NestedLoopPerf_ForEachLoop()
{
var list = Enumerable.Range(0, 10).ToList();

var r1 = Stopwatch.StartNew();
Bench(list);
r1.Stop();

Console.WriteLine($"r1={r1.Elapsed}");

static void Bench(List<int> list)
{
for (int i = 0; i < innerCount; i++)
{
Nest(0);
}

void Nest(int depth)
{
if(depth == maxDepth)
{
return;
}

foreach(var item in list)
{
Nest(depth + 1);
}
}
}
}
}

27 changes: 27 additions & 0 deletions Bug48179/Bug48179/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:49943/",
"sslPort": 44344
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Bug44269": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000"
}
}
}
5 changes: 5 additions & 0 deletions Bug48179/Bug48179/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Repro for issue https://github.com/dotnet/runtime/issues/48163

Reproducing this requires .NET 5.0.101 or later, mono and ninja installed.

Build with `dotnet build`
Binary file added Bug48179/Bug48179/aot.profile
Binary file not shown.

0 comments on commit 954148d

Please sign in to comment.