--- /dev/null
+<!--\r
+***********************************************************************************************\r
+<Build.Directory.targets>\r
+WARNING: DO NOT MODIFY this file. Incorrect changes to this file will make it\r
+ impossible to load or build your projects from the IDE.\r
+\r
+***********************************************************************************************\r
+-->\r
+\r
+<Project> \r
+ <Target Name="BuildDotnet" AfterTargets="TizenPackage" >\r
+ <Message Text="Tizen Build starts here ------------" Importance="high"/>\r
+ <Message Text="$(MSBuildProjectDirectory)" Importance="high"/>\r
+ <PropertyGroup>\r
+ <WorkspaceFolder>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))</WorkspaceFolder>\r
+ </PropertyGroup>\r
+ <Message Text="Workspace: '$(WorkspaceFolder)'" Importance="high" />\r
+\r
+ <Exec Command="C:\tizen-studio\tools\tizen-core\tz.exe pack -S $(ProjectDir) $(WorkspaceFolder)"> </Exec>\r
+ </Target>\r
+</Project>\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroArguments\r
+ {\r
+ [Params(true, false)] // Arguments can be combined with Params\r
+ public bool AddExtra5Milliseconds;\r
+\r
+ [Benchmark]\r
+ [Arguments(100, 10)]\r
+ [Arguments(100, 20)]\r
+ [Arguments(200, 10)]\r
+ [Arguments(200, 20)]\r
+ public void Benchmark(int a, int b)\r
+ {\r
+ if (AddExtra5Milliseconds)\r
+ Thread.Sleep(a + b + 5);\r
+ else\r
+ Thread.Sleep(a + b);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroArgumentsSource\r
+ {\r
+ [Benchmark]\r
+ [ArgumentsSource(nameof(Numbers))]\r
+ public double ManyArguments(double x, double y) => Math.Pow(x, y);\r
+\r
+ public IEnumerable<object[]> Numbers() // for multiple arguments it's an IEnumerable of array of objects (object[])\r
+ {\r
+ yield return new object[] { 1.0, 1.0 };\r
+ yield return new object[] { 2.0, 2.0 };\r
+ yield return new object[] { 4.0, 4.0 };\r
+ yield return new object[] { 10.0, 10.0 };\r
+ }\r
+\r
+ [Benchmark]\r
+ [ArgumentsSource(nameof(TimeSpans))]\r
+ public void SingleArgument(TimeSpan time) => Thread.Sleep(time);\r
+\r
+ public IEnumerable<object> TimeSpans() // for single argument it's an IEnumerable of objects (object)\r
+ {\r
+ yield return TimeSpan.FromMilliseconds(10);\r
+ yield return TimeSpan.FromMilliseconds(100);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroArrayParam\r
+ {\r
+ [Benchmark]\r
+ [ArgumentsSource(nameof(Data))]\r
+ public int ArrayIndexOf(int[] array, int value)\r
+ => Array.IndexOf(array, value);\r
+\r
+ [Benchmark]\r
+ [ArgumentsSource(nameof(Data))]\r
+ public int ManualIndexOf(int[] array, int value)\r
+ {\r
+ for (int i = 0; i < array.Length; i++)\r
+ if (array[i] == value)\r
+ return i;\r
+\r
+ return -1;\r
+ }\r
+\r
+ public IEnumerable<object[]> Data()\r
+ {\r
+ yield return new object[] { new int[] { 1, 2, 3 }, 4 };\r
+ yield return new object[] { Enumerable.Range(0, 100).ToArray(), 4 };\r
+ yield return new object[] { Enumerable.Range(0, 100).ToArray(), 101 };\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // It is very easy to use BenchmarkDotNet. You should just create a class\r
+ public class IntroBasic\r
+ {\r
+ // And define a method with the Benchmark attribute\r
+ [Benchmark]\r
+ public void Sleep() => Thread.Sleep(10);\r
+\r
+ // You can write a description for your method.\r
+ [Benchmark(Description = "Thread.Sleep(10)")]\r
+ public void SleepWithDescription() => Thread.Sleep(10);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroBenchmarkBaseline\r
+ {\r
+ [Benchmark]\r
+ public void Time50() => Thread.Sleep(50);\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public void Time100() => Thread.Sleep(100);\r
+\r
+ [Benchmark]\r
+ public void Time150() => Thread.Sleep(150);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DryJob]\r
+ [CategoriesColumn]\r
+ [BenchmarkCategory("Awesome")]\r
+ [AnyCategoriesFilter("A", "1")]\r
+ public class IntroCategories\r
+ {\r
+ [Benchmark]\r
+ [BenchmarkCategory("A", "1")]\r
+ public void A1() => Thread.Sleep(10); // Will be benchmarked\r
+\r
+ [Benchmark]\r
+ [BenchmarkCategory("A", "2")]\r
+ public void A2() => Thread.Sleep(10); // Will be benchmarked\r
+\r
+ [Benchmark]\r
+ [BenchmarkCategory("B", "1")]\r
+ public void B1() => Thread.Sleep(10); // Will be benchmarked\r
+\r
+ [Benchmark]\r
+ [BenchmarkCategory("B", "2")]\r
+ public void B2() => Thread.Sleep(10);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]\r
+ [CategoriesColumn]\r
+ public class IntroCategoryBaseline\r
+ {\r
+ [BenchmarkCategory("Fast"), Benchmark(Baseline = true)]\r
+ public void Time50() => Thread.Sleep(50);\r
+\r
+ [BenchmarkCategory("Fast"), Benchmark]\r
+ public void Time100() => Thread.Sleep(100);\r
+\r
+ [BenchmarkCategory("Slow"), Benchmark(Baseline = true)]\r
+ public void Time550() => Thread.Sleep(550);\r
+\r
+ [BenchmarkCategory("Slow"), Benchmark]\r
+ public void Time600() => Thread.Sleep(600);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Running;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Reflection;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DryJob]\r
+ [CategoriesColumn]\r
+ [CustomCategoryDiscoverer]\r
+ public class IntroCategoryDiscoverer\r
+ {\r
+ private class CustomCategoryDiscoverer : DefaultCategoryDiscoverer\r
+ {\r
+ public override string[] GetCategories(MethodInfo method)\r
+ {\r
+ var categories = new List<string>();\r
+ categories.AddRange(base.GetCategories(method));\r
+ categories.Add("All");\r
+ categories.Add(method.Name.Substring(0, 1));\r
+ return categories.ToArray();\r
+ }\r
+ }\r
+\r
+ [AttributeUsage(AttributeTargets.Class)]\r
+ private class CustomCategoryDiscovererAttribute : Attribute, IConfigSource\r
+ {\r
+ public CustomCategoryDiscovererAttribute()\r
+ {\r
+ Config = ManualConfig.CreateEmpty()\r
+ .WithCategoryDiscoverer(new CustomCategoryDiscoverer());\r
+ }\r
+\r
+ public IConfig Config { get; }\r
+ }\r
+\r
+\r
+ [Benchmark]\r
+ public void Foo() { }\r
+\r
+ [Benchmark]\r
+ public void Bar() { }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [SimpleJob(RunStrategy.ColdStart, iterationCount: 5)]\r
+ [MinColumn, MaxColumn, MeanColumn, MedianColumn]\r
+ public class IntroColdStart\r
+ {\r
+ private bool firstCall;\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ if (firstCall == false)\r
+ {\r
+ firstCall = true;\r
+ Console.WriteLine("// First call");\r
+ Thread.Sleep(1000);\r
+ }\r
+ else\r
+ Thread.Sleep(10);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroComparableComplexParam\r
+ {\r
+ [ParamsSource(nameof(ValuesForA))]\r
+ public ComplexParam? A { get; set; }\r
+\r
+ public IEnumerable<ComplexParam> ValuesForA => new[] { new ComplexParam(1, "First"), new ComplexParam(2, "Second") };\r
+\r
+ [Benchmark]\r
+ public object? Benchmark() => A;\r
+\r
+ // Only non generic IComparable is required to provide custom order behavior, but implementing IComparable<> too is customary.\r
+ public class ComplexParam : IComparable<ComplexParam>, IComparable\r
+ {\r
+ public ComplexParam(int value, string name)\r
+ {\r
+ Value = value;\r
+ Name = name;\r
+ }\r
+\r
+ public int Value { get; set; }\r
+\r
+ public string Name { get; set; }\r
+\r
+ public override string ToString() => Name;\r
+\r
+ public int CompareTo(ComplexParam? other) => other == null ? 1 : Value.CompareTo(other.Value);\r
+\r
+ public int CompareTo(object obj) => obj is ComplexParam other ? CompareTo(other) : throw new ArgumentException();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [MyConfigSource(Jit.LegacyJit, Jit.RyuJit)]\r
+ public class IntroConfigSource\r
+ {\r
+ /// <summary>\r
+ /// Dry-x64 jobs for specific jits\r
+ /// </summary>\r
+ private class MyConfigSourceAttribute : Attribute, IConfigSource\r
+ {\r
+ public IConfig Config { get; }\r
+\r
+ public MyConfigSourceAttribute(params Jit[] jits)\r
+ {\r
+ var jobs = jits\r
+ .Select(jit => new Job(Job.Dry) { Environment = { Jit = jit, Platform = Platform.X64 } })\r
+ .ToArray();\r
+ Config = ManualConfig.CreateEmpty().AddJob(jobs);\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ Thread.Sleep(10);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Analysers;\r
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Columns;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Exporters.Csv;\r
+using BenchmarkDotNet.Exporters;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Loggers;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ public class IntroConfigUnion\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.Dry);\r
+ AddLogger(ConsoleLogger.Default);\r
+ AddColumn(TargetMethodColumn.Method, StatisticColumn.Max);\r
+ AddExporter(RPlotExporter.Default, CsvExporter.Default);\r
+ AddAnalyser(EnvironmentAnalyser.Default);\r
+ UnionRule = ConfigUnionRule.AlwaysUseLocal;\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ Thread.Sleep(10);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Running;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // *** Attribute Style ***\r
+\r
+ [MonoJob("Mono x64", @"C:\Program Files\Mono\bin\mono.exe")]\r
+ [MonoJob("Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe")]\r
+ public class IntroCustomMono\r
+ {\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+\r
+ // *** Object Style ***\r
+\r
+ [Config(typeof(Config))]\r
+ public class IntroCustomMonoObjectStyle\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(\r
+ "Mono x64", @"C:\Program Files\Mono\bin\mono.exe")));\r
+ AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(\r
+ "Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe")));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+\r
+ // ** Object Style, Using AOT **\r
+\r
+ [Config(typeof(Config))]\r
+ public class IntroCustomMonoObjectStyleAot\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public void AddMono(string name, string mono_top_dir)\r
+ {\r
+ var aot_compile_args = "--aot=llvm";\r
+ var mono_bcl = $@"{mono_top_dir}\lib\mono\4.5";\r
+ var mono_bin = $@"{mono_top_dir}\bin\mono.exe";\r
+ AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(\r
+ name, mono_bin, aot_compile_args, mono_bcl)));\r
+ }\r
+\r
+ public Config()\r
+ {\r
+ AddMono("Mono x64", @"C:\Program Files\Mono");\r
+ AddMono("Mono x86", @"C:\Program Files (x86)\Mono");\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+\r
+ // *** Fluent Config ***\r
+\r
+ public class IntroCustomMonoFluentConfig\r
+ {\r
+ public static void Run()\r
+ {\r
+ BenchmarkRunner.Run<IntroCustomMonoFluentConfig>(ManualConfig\r
+ .CreateMinimumViable()\r
+ .AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(\r
+ "Mono x64", @"C:\Program Files\Mono\bin\mono.exe")))\r
+ .AddJob(Job.ShortRun.WithRuntime(new MonoRuntime(\r
+ "Mono x86", @"C:\Program Files (x86)\Mono\bin\mono.exe"))));\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(ConfigWithCustomArguments))]\r
+ public class IntroCustomMonoArguments\r
+ {\r
+ public class ConfigWithCustomArguments : ManualConfig\r
+ {\r
+ public ConfigWithCustomArguments()\r
+ {\r
+ // --optimize=MODE , -O=mode\r
+ // MODE is a comma separated list of optimizations. They also allow\r
+ // optimizations to be turned off by prefixing the optimization\r
+ // name with a minus sign.\r
+\r
+ AddJob(Job.Default\r
+ .WithRuntime(MonoRuntime.Default)\r
+ .WithArguments(new[] { new MonoArgument("--optimize=inline") })\r
+ .WithId("Inlining enabled"));\r
+ AddJob(Job.Default\r
+ .WithRuntime(MonoRuntime.Default)\r
+ .WithArguments(new[] { new MonoArgument("--optimize=-inline") })\r
+ .WithId("Inlining disabled"));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Sample()\r
+ {\r
+ ShouldGetInlined(); ShouldGetInlined(); ShouldGetInlined();\r
+ ShouldGetInlined(); ShouldGetInlined(); ShouldGetInlined();\r
+ ShouldGetInlined(); ShouldGetInlined(); ShouldGetInlined();\r
+ }\r
+\r
+ private void ShouldGetInlined() { }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroDeferredExecution\r
+ {\r
+ private readonly int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\r
+\r
+ private readonly Consumer consumer = new Consumer();\r
+\r
+ /// <summary>\r
+ /// this benchmark returns a deferred LINQ query which is NOT executed\r
+ /// so the benchmark measures the cost of creating the query, not the actual execution\r
+ /// this is WRONG\r
+ /// You can read more about LINQ and Deferred Execution <see href="https://blogs.msdn.microsoft.com/charlie/2007/12/10/linq-and-deferred-execution/">here</see>\r
+ /// </summary>\r
+ /// <returns>deferred LINQ query</returns>\r
+ [Benchmark]\r
+ public IEnumerable<int> Wrong() => from number in numbers orderby number descending select number;\r
+\r
+ /// <summary>\r
+ /// this benchmark uses .Consume extension method which executes given deferred query and consumes its result\r
+ /// so the benchmark measures the cost of creating the query and executing it\r
+ /// </summary>\r
+ [Benchmark]\r
+ public void Ok() => (from number in numbers orderby number descending select number).Consume(consumer);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Diagnosers;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DisassemblyDiagnoser(printInstructionAddresses: true, syntax: DisassemblySyntax.Masm)]\r
+ public class IntroDisassembly\r
+ {\r
+ private int[] field = Enumerable.Range(0, 100).ToArray();\r
+\r
+ [Benchmark]\r
+ public int SumLocal()\r
+ {\r
+ var local = field; // we use local variable that points to the field\r
+\r
+ int sum = 0;\r
+ for (int i = 0; i < local.Length; i++)\r
+ sum += local[i];\r
+\r
+ return sum;\r
+ }\r
+\r
+ [Benchmark]\r
+ public int SumField()\r
+ {\r
+ int sum = 0;\r
+ for (int i = 0; i < field.Length; i++)\r
+ sum += field[i];\r
+\r
+ return sum;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Diagnosers;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(MultipleJits))]\r
+ public class IntroDisassemblyAllJits\r
+ {\r
+ public class MultipleJits : ManualConfig\r
+ {\r
+ public MultipleJits()\r
+ {\r
+ AddJob(Job.ShortRun.WithPlatform(Platform.X86).WithRuntime(new MonoRuntime(name: "Mono x86", customPath: @"C:\Program Files (x86)\Mono\bin\mono.exe")));\r
+ AddJob(Job.ShortRun.WithPlatform(Platform.X64).WithRuntime(new MonoRuntime(name: "Mono x64", customPath: @"C:\Program Files\Mono\bin\mono.exe")));\r
+\r
+ AddJob(Job.ShortRun.WithJit(Jit.LegacyJit).WithPlatform(Platform.X86).WithRuntime(ClrRuntime.Net462));\r
+ AddJob(Job.ShortRun.WithJit(Jit.LegacyJit).WithPlatform(Platform.X64).WithRuntime(ClrRuntime.Net462));\r
+\r
+ AddJob(Job.ShortRun.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(ClrRuntime.Net462));\r
+\r
+ // RyuJit for .NET Core 5.0\r
+ AddJob(Job.ShortRun.WithJit(Jit.RyuJit).WithPlatform(Platform.X64).WithRuntime(CoreRuntime.Core50));\r
+\r
+ AddDiagnoser(new DisassemblyDiagnoser(new DisassemblyDiagnoserConfig(maxDepth: 3, exportDiff: true)));\r
+ }\r
+ }\r
+\r
+ private Increment increment = new Increment();\r
+\r
+ [Benchmark]\r
+ public int CallVirtualMethod() => increment.OperateTwice(10);\r
+\r
+ public abstract class Operation // abstract unary integer operation\r
+ {\r
+ public abstract int Operate(int input);\r
+\r
+ public int OperateTwice(int input) => Operate(Operate(input)); // two virtual calls to Operate\r
+ }\r
+\r
+ public sealed class Increment : Operation // concrete, sealed operation: increment by fixed amount\r
+ {\r
+ public readonly int Amount;\r
+ public Increment(int amount = 1) { Amount = amount; }\r
+\r
+ public override int Operate(int input) => input + Amount;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DisassemblyDiagnoser(maxDepth: 3)]\r
+ [DryJob]\r
+ public class IntroDisassemblyDry\r
+ {\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DisassemblyDiagnoser(printSource: true)]\r
+ [RyuJitX64Job]\r
+ public class IntroDisassemblyRyuJit\r
+ {\r
+ private int[] field = Enumerable.Range(0, 100).ToArray();\r
+\r
+ [Benchmark]\r
+ public int SumLocal()\r
+ {\r
+ var local = field; // we use local variable that points to the field\r
+\r
+ int sum = 0;\r
+ for (int i = 0; i < local.Length; i++)\r
+ sum += local[i];\r
+\r
+ return sum;\r
+ }\r
+\r
+ [Benchmark]\r
+ public int SumField()\r
+ {\r
+ int sum = 0;\r
+ for (int i = 0; i < field.Length; i++)\r
+ sum += field[i];\r
+\r
+ return sum;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Diagnostics.dotTrace;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // Enables dotTrace profiling for all jobs\r
+ [DotTraceDiagnoser]\r
+ // Adds the default "external-process" job\r
+ // Profiling is performed using dotTrace command-line Tools\r
+ // See: https://www.jetbrains.com/help/profiler/Performance_Profiling__Profiling_Using_the_Command_Line.html\r
+ [SimpleJob]\r
+ // Adds an "in-process" job\r
+ // Profiling is performed using dotTrace SelfApi\r
+ // NuGet reference: https://www.nuget.org/packages/JetBrains.Profiler.SelfApi\r
+ [InProcess]\r
+ public class IntroDotTraceDiagnoser\r
+ {\r
+ [Benchmark]\r
+ public void Fibonacci() => Fibonacci(30);\r
+\r
+ private static int Fibonacci(int n)\r
+ {\r
+ return n <= 1 ? n : Fibonacci(n - 1) + Fibonacci(n - 2);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(ConfigWithCustomEnvVars))]\r
+ public class IntroEnvVars\r
+ {\r
+ private class ConfigWithCustomEnvVars : ManualConfig\r
+ {\r
+ private const string JitNoInline = "COMPlus_JitNoInline";\r
+\r
+ public ConfigWithCustomEnvVars()\r
+ {\r
+ AddJob(Job.Default.WithRuntime(CoreRuntime.Core21).WithId("Inlining enabled"));\r
+ AddJob(Job.Default.WithRuntime(CoreRuntime.Core21)\r
+ .WithEnvironmentVariables(new EnvironmentVariable(JitNoInline, "1"))\r
+ .WithId("Inlining disabled"));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Diagnosers;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [ShortRunJob]\r
+ [EventPipeProfiler(EventPipeProfile.CpuSampling)]\r
+ public class IntroEventPipeProfiler\r
+ {\r
+ [Benchmark]\r
+ public void Sleep() => Thread.Sleep(2000);\r
+ }\r
+\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Diagnosers;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using Microsoft.Diagnostics.NETCore.Client;\r
+using Microsoft.Diagnostics.Tracing.Parsers;\r
+using System;\r
+using System.Buffers;\r
+using System.Collections.Generic;\r
+using System.Diagnostics.Tracing;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(CustomConfig))]\r
+ public class IntroEventPipeProfilerAdvanced\r
+ {\r
+ private class CustomConfig : ManualConfig\r
+ {\r
+ public CustomConfig()\r
+ {\r
+ AddJob(Job.ShortRun.WithRuntime(CoreRuntime.Core50));\r
+\r
+ var providers = new[]\r
+ {\r
+ new EventPipeProvider(ClrTraceEventParser.ProviderName, EventLevel.Verbose,\r
+ (long) (ClrTraceEventParser.Keywords.Exception\r
+ | ClrTraceEventParser.Keywords.GC\r
+ | ClrTraceEventParser.Keywords.Jit\r
+ | ClrTraceEventParser.Keywords.JitTracing // for the inlining events\r
+ | ClrTraceEventParser.Keywords.Loader\r
+ | ClrTraceEventParser.Keywords.NGen)),\r
+ new EventPipeProvider("System.Buffers.ArrayPoolEventSource", EventLevel.Informational, long.MaxValue),\r
+ };\r
+\r
+ AddDiagnoser(new EventPipeProfiler(providers: providers));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void RentAndReturn_Shared()\r
+ {\r
+ var pool = ArrayPool<byte>.Shared;\r
+ byte[] array = pool.Rent(10000);\r
+ pool.Return(array);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [ShortRunJob]\r
+ [MediumRunJob]\r
+ [KeepBenchmarkFiles]\r
+\r
+ [AsciiDocExporter]\r
+ [CsvExporter]\r
+ [CsvMeasurementsExporter]\r
+ [HtmlExporter]\r
+ [PlainExporter]\r
+ [RPlotExporter]\r
+ [JsonExporterAttribute.Brief]\r
+ [JsonExporterAttribute.BriefCompressed]\r
+ [JsonExporterAttribute.Full]\r
+ [JsonExporterAttribute.FullCompressed]\r
+ [MarkdownExporterAttribute.Default]\r
+ [MarkdownExporterAttribute.GitHub]\r
+ [MarkdownExporterAttribute.StackOverflow]\r
+ [MarkdownExporterAttribute.Atlassian]\r
+ [XmlExporterAttribute.Brief]\r
+ [XmlExporterAttribute.BriefCompressed]\r
+ [XmlExporterAttribute.Full]\r
+ [XmlExporterAttribute.FullCompressed]\r
+ public class IntroExport\r
+ {\r
+ private Random random = new Random(42);\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public void Sleep10() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ public void Sleep50Noisy() => Thread.Sleep(random.Next(100));\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Exporters.Json;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // *** Attribute style ***\r
+\r
+ [DryJob]\r
+ [JsonExporterAttribute.Brief]\r
+ [JsonExporterAttribute.Full]\r
+ [JsonExporterAttribute.BriefCompressed]\r
+ [JsonExporterAttribute.FullCompressed]\r
+ [JsonExporter("-custom", indentJson: true, excludeMeasurements: true)]\r
+ public class IntroExportJson\r
+ {\r
+ [Benchmark] public void Sleep10() => Thread.Sleep(10);\r
+ [Benchmark] public void Sleep20() => Thread.Sleep(20);\r
+ }\r
+\r
+ // *** Object style ***\r
+\r
+ [Config(typeof(Config))]\r
+ public class IntroJsonExportObjectStyle\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddExporter(JsonExporter.Brief);\r
+ AddExporter(JsonExporter.Brief);\r
+ AddExporter(JsonExporter.Full);\r
+ AddExporter(JsonExporter.BriefCompressed);\r
+ AddExporter(JsonExporter.FullCompressed);\r
+ AddExporter(JsonExporter.Custom("-custom", indentJson: true, excludeMeasurements: true));\r
+ }\r
+ }\r
+\r
+ [Benchmark] public void Sleep10() => Thread.Sleep(10);\r
+ [Benchmark] public void Sleep20() => Thread.Sleep(20);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DryJob]\r
+ [XmlExporterAttribute.Brief]\r
+ [XmlExporterAttribute.Full]\r
+ [XmlExporterAttribute.BriefCompressed]\r
+ [XmlExporterAttribute.FullCompressed]\r
+ [XmlExporter("-custom", indentXml: true, excludeMeasurements: true)]\r
+ public class IntroExportXml\r
+ {\r
+ [Benchmark] public void Sleep10() => Thread.Sleep(10);\r
+ [Benchmark] public void Sleep20() => Thread.Sleep(20);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Filters;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DryJob]\r
+ [Config(typeof(Config))]\r
+ public class IntroFilters\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ // We will benchmark ONLY method with\r
+ // names (which contains "A" OR "1") AND (have length < 3)\r
+ public Config()\r
+ {\r
+ // benchmark with names which contains "A" OR "1"\r
+ AddFilter(new DisjunctionFilter(\r
+ new NameFilter(name => name.Contains("A")),\r
+ new NameFilter(name => name.Contains("1"))\r
+ ));\r
+\r
+ // benchmark with names with length < 3\r
+ AddFilter(new NameFilter(name => name.Length < 3));\r
+ }\r
+ }\r
+\r
+ [Benchmark] public void A1() => Thread.Sleep(10); // Will be benchmarked\r
+ [Benchmark] public void A2() => Thread.Sleep(10); // Will be benchmarked\r
+ [Benchmark] public void A3() => Thread.Sleep(10); // Will be benchmarked\r
+ [Benchmark] public void B1() => Thread.Sleep(10); // Will be benchmarked\r
+ [Benchmark] public void B2() => Thread.Sleep(10);\r
+ [Benchmark] public void B3() => Thread.Sleep(10);\r
+ [Benchmark] public void C1() => Thread.Sleep(10); // Will be benchmarked\r
+ [Benchmark] public void C2() => Thread.Sleep(10);\r
+ [Benchmark] public void C3() => Thread.Sleep(10);\r
+ [Benchmark] public void Aaa() => Thread.Sleep(10);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Running;\r
+using BenchmarkDotNet.Validators;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Security.Cryptography;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class Algo_Md5VsSha256\r
+ {\r
+ private const int N = 10000;\r
+ private readonly byte[] data;\r
+\r
+ private readonly MD5 md5 = MD5.Create();\r
+ private readonly SHA256 sha256 = SHA256.Create();\r
+\r
+ public Algo_Md5VsSha256()\r
+ {\r
+ data = new byte[N];\r
+ new Random(42).NextBytes(data);\r
+ }\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public byte[] Md5() => md5.ComputeHash(data);\r
+\r
+ [Benchmark]\r
+ public byte[] Sha256() => sha256.ComputeHash(data);\r
+ }\r
+\r
+ public class IntroFluentConfigBuilder\r
+ {\r
+ public static void Run()\r
+ {\r
+ BenchmarkRunner\r
+ .Run<Algo_Md5VsSha256>(\r
+ DefaultConfig.Instance\r
+ .AddJob(Job.Default.WithRuntime(ClrRuntime.Net462))\r
+ .AddJob(Job.Default.WithRuntime(CoreRuntime.Core21))\r
+ .AddValidator(ExecutionValidator.FailOnError));\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Order;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Runtime.CompilerServices;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ [Orderer(SummaryOrderPolicy.FastestToSlowest)]\r
+ [MemoryDiagnoser]\r
+ public class IntroGcMode\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.MediumRun.WithGcServer(true).WithGcForce(true).WithId("ServerForce"));\r
+ AddJob(Job.MediumRun.WithGcServer(true).WithGcForce(false).WithId("Server"));\r
+ AddJob(Job.MediumRun.WithGcServer(false).WithGcForce(true).WithId("Workstation"));\r
+ AddJob(Job.MediumRun.WithGcServer(false).WithGcForce(false).WithId("WorkstationForce"));\r
+ }\r
+ }\r
+\r
+ [Benchmark(Description = "new byte[10kB]")]\r
+ public byte[] Allocate()\r
+ {\r
+ return new byte[10000];\r
+ }\r
+\r
+ [Benchmark(Description = "stackalloc byte[10kB]")]\r
+ public unsafe void AllocateWithStackalloc()\r
+ {\r
+ var array = stackalloc byte[10000];\r
+ Consume(array);\r
+ }\r
+\r
+ [MethodImpl(MethodImplOptions.NoInlining)]\r
+ private static unsafe void Consume(byte* input)\r
+ {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [GenericTypeArguments(typeof(int))]\r
+ [GenericTypeArguments(typeof(char))]\r
+ public class IntroGenericTypeArguments<T>\r
+ {\r
+ [Benchmark] public T Create() => Activator.CreateInstance<T>();\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Diagnosers;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [HardwareCounters(\r
+ HardwareCounter.BranchMispredictions,\r
+ HardwareCounter.BranchInstructions)]\r
+ public class IntroHardwareCounters\r
+ {\r
+ private const int N = 32767;\r
+ private readonly int[] sorted, unsorted;\r
+\r
+ public IntroHardwareCounters()\r
+ {\r
+ var random = new Random(0);\r
+ unsorted = new int[N];\r
+ sorted = new int[N];\r
+ for (int i = 0; i < N; i++)\r
+ sorted[i] = unsorted[i] = random.Next(256);\r
+ Array.Sort(sorted);\r
+ }\r
+\r
+ private static int Branch(int[] data)\r
+ {\r
+ int sum = 0;\r
+ for (int i = 0; i < N; i++)\r
+ if (data[i] >= 128)\r
+ sum += data[i];\r
+ return sum;\r
+ }\r
+\r
+ private static int Branchless(int[] data)\r
+ {\r
+ int sum = 0;\r
+ for (int i = 0; i < N; i++)\r
+ {\r
+ int t = (data[i] - 128) >> 31;\r
+ sum += ~t & data[i];\r
+ }\r
+ return sum;\r
+ }\r
+\r
+ [Benchmark]\r
+ public int SortedBranch() => Branch(sorted);\r
+\r
+ [Benchmark]\r
+ public int UnsortedBranch() => Branch(unsorted);\r
+\r
+ [Benchmark]\r
+ public int SortedBranchless() => Branchless(sorted);\r
+\r
+ [Benchmark]\r
+ public int UnsortedBranchless() => Branchless(unsorted);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Order;\r
+using BenchmarkDotNet.Toolchains.InProcess.Emit;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Runtime.CompilerServices;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ [Orderer(SummaryOrderPolicy.FastestToSlowest)]\r
+ [MemoryDiagnoser]\r
+ public class IntroInProcess\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.MediumRun\r
+ .WithLaunchCount(1)\r
+ .WithId("OutOfProc"));\r
+\r
+ AddJob(Job.MediumRun\r
+ .WithLaunchCount(1)\r
+ .WithToolchain(InProcessEmitToolchain.Instance)\r
+ .WithId("InProcess"));\r
+ }\r
+ }\r
+\r
+ [Benchmark(Description = "new byte[10kB]")]\r
+ public byte[] Allocate()\r
+ {\r
+ return new byte[10000];\r
+ }\r
+\r
+ [Benchmark(Description = "stackalloc byte[10kB]")]\r
+ public unsafe void AllocateWithStackalloc()\r
+ {\r
+ var array = stackalloc byte[10000];\r
+ Consume(array);\r
+ }\r
+\r
+ [MethodImpl(MethodImplOptions.NoInlining)]\r
+ private static unsafe void Consume(byte* input)\r
+ {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Runtime.CompilerServices;\r
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Order;\r
+using BenchmarkDotNet.Toolchains.InProcess;\r
+using BenchmarkDotNet.Toolchains.InProcess.Emit;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ [Orderer(SummaryOrderPolicy.FastestToSlowest)]\r
+ [MemoryDiagnoser]\r
+ public class IntroInProcessWrongEnv\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ var wrongPlatform = Environment.Is64BitProcess\r
+ ? Platform.X64\r
+ : Platform.X86;\r
+\r
+ AddJob(Job.MediumRun\r
+ .WithLaunchCount(1)\r
+ .WithPlatform(wrongPlatform)\r
+ .WithToolchain(InProcessEmitToolchain.Instance)\r
+ .WithId("InProcess"));\r
+\r
+ AddValidator(InProcessValidator.DontFailOnError);\r
+ }\r
+ }\r
+\r
+ [Benchmark(Description = "new byte[10kB]")]\r
+ public byte[] Allocate()\r
+ {\r
+ return new byte[10000];\r
+ }\r
+\r
+ [Benchmark(Description = "stackalloc byte[10kB]")]\r
+ public unsafe void AllocateWithStackalloc()\r
+ {\r
+ var array = stackalloc byte[10000];\r
+ Consume(array);\r
+ }\r
+\r
+ [MethodImpl(MethodImplOptions.NoInlining)]\r
+ private static unsafe void Consume(byte* input)\r
+ {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Runtime.CompilerServices;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [BenchmarkDotNet.Diagnostics.Windows.Configs.InliningDiagnoser(logFailuresOnly: false, allowedNamespaces: new[] { "BenchmarkDotNet.Samples" })]\r
+ public class IntroInliningDiagnoser\r
+ {\r
+ [Benchmark]\r
+ public int IterationTest()\r
+ {\r
+ int j = 0;\r
+ for (int i = 0; i < short.MaxValue; ++i)\r
+ {\r
+ j = i + AddThree(i);\r
+ }\r
+\r
+ return j + ReturnFive() + AddThree(ReturnFive());\r
+ }\r
+\r
+ [Benchmark]\r
+ public int SplitJoin()\r
+ => string.Join(",", new string[1000]).Split(',').Length;\r
+\r
+ private int ReturnFive()\r
+ {\r
+ return 5;\r
+ }\r
+\r
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]\r
+ private int AddThree(int a)\r
+ {\r
+ return a + 3;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System.Threading;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+\r
+ [BenchmarkDotNet.Diagnostics.Windows.Configs.JitStatsDiagnoser]\r
+ public class IntroJitStatsDiagnoser\r
+ {\r
+ [Benchmark]\r
+ public void Sleep() => Thread.Sleep(10);\r
+ }\r
+\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [SimpleJob(runtimeMoniker: RuntimeMoniker.Net462, baseline: true)]\r
+ [SimpleJob(runtimeMoniker: RuntimeMoniker.Mono)]\r
+ [SimpleJob(runtimeMoniker: RuntimeMoniker.Net50)]\r
+ public class IntroJobBaseline\r
+ {\r
+ [Benchmark]\r
+ public int SplitJoin()\r
+ => string.Join(",", new string[1000]).Split(',').Length;\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // Run BenchmarkSwitcher with arguments: "--join --category=IntroJoinA"\r
+\r
+ [DryJob]\r
+ public class IntroJoin1\r
+ {\r
+ [Benchmark]\r
+ [BenchmarkCategory("IntroJoinA")]\r
+ public void A() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ [BenchmarkCategory("IntroJoinB")]\r
+ public void B() => Thread.Sleep(10);\r
+ }\r
+\r
+ [DryJob]\r
+ public class IntroJoin2\r
+ {\r
+ [Benchmark]\r
+ [BenchmarkCategory("IntroJoinA")]\r
+ public void A() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ [BenchmarkCategory("IntroJoinB")]\r
+ public void B() => Thread.Sleep(10);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [MemoryDiagnoser]\r
+ [Config(typeof(Config))]\r
+ public class IntroLargeAddressAware\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.Default\r
+ .WithRuntime(ClrRuntime.Net462)\r
+ .WithPlatform(Platform.X86)\r
+ .WithLargeAddressAware(value: RuntimeInformation.IsOSPlatform(OSPlatform.Windows))\r
+ .WithId("Framework"));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void AllocateMoreThan2GB()\r
+ {\r
+ const int oneGB = 1024 * 1024 * 1024;\r
+ const int halfGB = oneGB / 2;\r
+ byte[] bytes1 = new byte[oneGB];\r
+ byte[] bytes2 = new byte[oneGB];\r
+ byte[] bytes3 = new byte[halfGB];\r
+ GC.KeepAlive(bytes1);\r
+ GC.KeepAlive(bytes2);\r
+ GC.KeepAlive(bytes3);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [SimpleJob(RunStrategy.Monitoring, iterationCount: 10, id: "MonitoringJob")]\r
+ [MinColumn, Q1Column, Q3Column, MaxColumn]\r
+ public class IntroMonitoring\r
+ {\r
+ private Random random = new Random(42);\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ Thread.Sleep(random.Next(10) * 10);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [MValueColumn]\r
+ [SimpleJob(RunStrategy.Throughput, 1, 0, -1, 1, "MyJob")]\r
+ public class IntroMultimodal\r
+ {\r
+ private readonly Random rnd = new Random(42);\r
+\r
+ private void Multimodal(int n)\r
+ => Thread.Sleep((rnd.Next(n) + 1) * 100);\r
+\r
+ [Benchmark] public void Unimodal() => Multimodal(1);\r
+ [Benchmark] public void Bimodal() => Multimodal(2);\r
+ [Benchmark] public void Trimodal() => Multimodal(3);\r
+ [Benchmark] public void Quadrimodal() => Multimodal(4);\r
+ }\r
+}\r
--- /dev/null
+using System;\r
+using System.Drawing;\r
+using System.Runtime.InteropServices;\r
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Diagnostics.Windows.Configs;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [ShortRunJob]\r
+ [NativeMemoryProfiler]\r
+ [MemoryDiagnoser]\r
+ public class IntroNativeMemory\r
+ {\r
+ [Benchmark]\r
+ public void BitmapWithLeaks()\r
+ {\r
+ var flag = new Bitmap(200, 100);\r
+ var graphics = Graphics.FromImage(flag);\r
+ var blackPen = new Pen(Color.Black, 3);\r
+ graphics.DrawLine(blackPen, 100, 100, 500, 100);\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Bitmap()\r
+ {\r
+ using (var flag = new Bitmap(200, 100))\r
+ {\r
+ using (var graphics = Graphics.FromImage(flag))\r
+ {\r
+ using (var blackPen = new Pen(Color.Black, 3))\r
+ {\r
+ graphics.DrawLine(blackPen, 100, 100, 500, 100);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ private const int Size = 20; // Greater value could cause System.OutOfMemoryException for test with memory leaks.\r
+ private int ArraySize = Size * Marshal.SizeOf(typeof(int));\r
+\r
+ [Benchmark]\r
+ public unsafe void AllocHGlobal()\r
+ {\r
+ IntPtr unmanagedHandle = Marshal.AllocHGlobal(ArraySize);\r
+ Span<byte> unmanaged = new Span<byte>(unmanagedHandle.ToPointer(), ArraySize);\r
+ Marshal.FreeHGlobal(unmanagedHandle);\r
+ }\r
+\r
+ [Benchmark]\r
+ public unsafe void AllocHGlobalWithLeaks()\r
+ {\r
+ IntPtr unmanagedHandle = Marshal.AllocHGlobal(ArraySize);\r
+ Span<byte> unmanaged = new Span<byte>(unmanagedHandle.ToPointer(), ArraySize);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Jobs;\r
+using Newtonsoft.Json;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ /// <summary>\r
+ /// Benchmarks between various versions of a NuGet package\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Only supported with the CsProjCoreToolchain toolchain\r
+ /// </remarks>\r
+ [Config(typeof(Config))]\r
+ public class IntroNuGet\r
+ {\r
+ // Specify jobs with different versions of the same NuGet package to benchmark.\r
+ // The NuGet versions referenced on these jobs must be greater or equal to the\r
+ // same NuGet version referenced in this benchmark project.\r
+ // Example: This benchmark project references Newtonsoft.Json 9.0.1\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ var baseJob = Job.MediumRun;\r
+\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "11.0.2").WithId("11.0.2"));\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "11.0.1").WithId("11.0.1"));\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "10.0.3").WithId("10.0.3"));\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "10.0.2").WithId("10.0.2"));\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "10.0.1").WithId("10.0.1"));\r
+ AddJob(baseJob.WithNuGet("Newtonsoft.Json", "9.0.1").WithId("9.0.1"));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void SerializeAnonymousObject()\r
+ => JsonConvert.SerializeObject(\r
+ new { hello = "world", price = 1.99, now = DateTime.UtcNow });\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Order;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Orderer(SummaryOrderPolicy.FastestToSlowest, MethodOrderPolicy.Declared)]\r
+ [DryJob]\r
+ public class IntroOrderAttr\r
+ {\r
+ [Params(1, 2, 3)]\r
+ public int X { get; set; }\r
+\r
+ [Benchmark]\r
+ public void Slow() => Thread.Sleep(X * 100);\r
+\r
+ [Benchmark]\r
+ public void Fast() => Thread.Sleep(X * 50);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Order;\r
+using BenchmarkDotNet.Reports;\r
+using BenchmarkDotNet.Running;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Collections.Immutable;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ [DryJob]\r
+ [RankColumn]\r
+ public class IntroOrderManual\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config() => Orderer = new FastestToSlowestOrderer();\r
+\r
+ private class FastestToSlowestOrderer : IOrderer\r
+ {\r
+ public IEnumerable<BenchmarkCase> GetExecutionOrder(ImmutableArray<BenchmarkCase> benchmarksCase,\r
+ IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>\r
+ from benchmark in benchmarksCase\r
+ orderby benchmark.Parameters["X"] descending,\r
+ benchmark.Descriptor.WorkloadMethodDisplayInfo\r
+ select benchmark;\r
+\r
+ public IEnumerable<BenchmarkCase> GetSummaryOrder(ImmutableArray<BenchmarkCase> benchmarksCase, Summary summary) =>\r
+ from benchmark in benchmarksCase\r
+ orderby summary[benchmark].ResultStatistics.Mean\r
+ select benchmark;\r
+\r
+ public string GetHighlightGroupKey(BenchmarkCase benchmarkCase) => null;\r
+\r
+ public string GetLogicalGroupKey(ImmutableArray<BenchmarkCase> allBenchmarksCases, BenchmarkCase benchmarkCase) =>\r
+ benchmarkCase.Job.DisplayInfo + "_" + benchmarkCase.Parameters.DisplayInfo;\r
+\r
+ public IEnumerable<IGrouping<string, BenchmarkCase>> GetLogicalGroupOrder(IEnumerable<IGrouping<string, BenchmarkCase>> logicalGroups,\r
+ IEnumerable<BenchmarkLogicalGroupRule>? order = null) =>\r
+ logicalGroups.OrderBy(it => it.Key);\r
+\r
+ public bool SeparateLogicalGroups => true;\r
+ }\r
+ }\r
+\r
+ [Params(1, 2, 3)]\r
+ public int X { get; set; }\r
+\r
+ [Benchmark]\r
+ public void Fast() => Thread.Sleep(X * 50);\r
+\r
+ [Benchmark]\r
+ public void Slow() => Thread.Sleep(X * 100);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Jobs;\r
+using Perfolizer.Mathematics.OutlierDetection;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ public class IntroOutliers\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ var jobBase = Job.Default.WithWarmupCount(0).WithIterationCount(10).WithInvocationCount(1).WithUnrollFactor(1);\r
+ AddJob(jobBase.WithOutlierMode(OutlierMode.DontRemove).WithId("DontRemoveOutliers"));\r
+ AddJob(jobBase.WithOutlierMode(OutlierMode.RemoveUpper).WithId("RemoveUpperOutliers"));\r
+ }\r
+ }\r
+\r
+ private int counter;\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ counter++;\r
+ int noise = counter % 10 == 0 ? 500 : 0;\r
+ Thread.Sleep(100 + noise);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroParams\r
+ {\r
+ [Params(100, 200)]\r
+ public int A { get; set; }\r
+\r
+ [Params(10, 20)]\r
+ public int B { get; set; }\r
+\r
+ [Benchmark]\r
+ public void Benchmark() => Thread.Sleep(A + B + 5);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [DryJob]\r
+ public class IntroParamsAllValues\r
+ {\r
+ public enum CustomEnum\r
+ {\r
+ One = 1,\r
+ Two,\r
+ Three\r
+ }\r
+\r
+ [ParamsAllValues]\r
+ public CustomEnum E { get; set; }\r
+\r
+ [ParamsAllValues]\r
+ public bool? B { get; set; }\r
+\r
+ [Benchmark]\r
+ public void Benchmark()\r
+ {\r
+ Thread.Sleep(\r
+ (int)E * 100 +\r
+ (B == true ? 20 : B == false ? 10 : 0));\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroParamsSource\r
+ {\r
+ // property with public setter\r
+ [ParamsSource(nameof(ValuesForA))]\r
+ public int A { get; set; }\r
+\r
+ // public field\r
+ [ParamsSource(nameof(ValuesForB))]\r
+ public int B;\r
+\r
+ // public property\r
+ public IEnumerable<int> ValuesForA => new[] { 100, 200 };\r
+\r
+ // public static method\r
+ public static IEnumerable<int> ValuesForB() => new[] { 10, 20 };\r
+\r
+ [Benchmark]\r
+ public void Benchmark() => Thread.Sleep(A + B + 5);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Columns;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // Using percentiles for adequate timings representation\r
+ [Config(typeof(Config))]\r
+ [SimpleJob(RunStrategy.ColdStart, launchCount: 4,\r
+ warmupCount: 3, iterationCount: 20, id: "MyJob")]\r
+ public class IntroPercentiles\r
+ {\r
+ // To share between runs.\r
+ // DO NOT do this in production code. The System.Random IS NOT thread safe.\r
+ private static readonly Random Rnd = new Random();\r
+\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddColumn(\r
+ StatisticColumn.P0,\r
+ StatisticColumn.P25,\r
+ StatisticColumn.P50,\r
+ StatisticColumn.P67,\r
+ StatisticColumn.P80,\r
+ StatisticColumn.P85,\r
+ StatisticColumn.P90,\r
+ StatisticColumn.P95,\r
+ StatisticColumn.P100);\r
+ }\r
+ }\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public void ConstantDelays() => Thread.Sleep(20);\r
+\r
+ [Benchmark]\r
+ public void RandomDelays() => Thread.Sleep(10 + (int)(20 * Rnd.NextDouble()));\r
+\r
+ [Benchmark]\r
+ public void RareDelays()\r
+ {\r
+ int rndTime = 10;\r
+ // Bigger delays for 15% of the runs\r
+ if (Rnd.NextDouble() > 0.85)\r
+ {\r
+ rndTime += 30;\r
+ }\r
+\r
+ Thread.Sleep(rndTime);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [Config(typeof(Config))]\r
+ public class IntroPowerPlan\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.MediumRun.WithPowerPlan(new Guid("e9a42b02-d5df-448d-aa00-03f14749eb61")));\r
+ AddJob(Job.MediumRun.WithPowerPlan(PowerPlan.UltimatePerformance));\r
+ AddJob(Job.MediumRun.WithPowerPlan(PowerPlan.UserPowerPlan));\r
+ AddJob(Job.MediumRun.WithPowerPlan(PowerPlan.HighPerformance));\r
+ AddJob(Job.MediumRun.WithPowerPlan(PowerPlan.Balanced));\r
+ AddJob(Job.MediumRun.WithPowerPlan(PowerPlan.PowerSaver));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public int IterationTest()\r
+ {\r
+ int j = 0;\r
+ for (int i = 0; i < short.MaxValue; ++i)\r
+ {\r
+ j = i;\r
+ }\r
+\r
+ return j;\r
+ }\r
+\r
+ [Benchmark]\r
+ public int SplitJoin()\r
+ => string.Join(",", new string[1000]).Split(',').Length;\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Mathematics;\r
+using BenchmarkDotNet.Order;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [ShortRunJob]\r
+ [Orderer(SummaryOrderPolicy.FastestToSlowest)]\r
+ [RankColumn(NumeralSystem.Arabic)]\r
+ [RankColumn(NumeralSystem.Roman)]\r
+ [RankColumn(NumeralSystem.Stars)]\r
+ public class IntroRankColumn\r
+ {\r
+ [Params(1, 2)]\r
+ public int Factor;\r
+\r
+ [Benchmark]\r
+ public void Foo() => Thread.Sleep(Factor * 100);\r
+\r
+ [Benchmark]\r
+ public void Bar() => Thread.Sleep(Factor * 200);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using Perfolizer.Mathematics.OutlierDetection;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // Don't remove outliers\r
+ [Outliers(OutlierMode.DontRemove)]\r
+ // Skip jitting, pilot, warmup; measure 10 iterations\r
+ [SimpleJob(RunStrategy.Monitoring, iterationCount: 10, invocationCount: 1)]\r
+ public class IntroRatioSD\r
+ {\r
+ private int counter;\r
+\r
+ [GlobalSetup]\r
+ public void Setup() => counter = 0;\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public void Base()\r
+ {\r
+ Thread.Sleep(100);\r
+ if (++counter % 7 == 0)\r
+ Thread.Sleep(5000); // Emulate outlier\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Slow() => Thread.Sleep(200);\r
+\r
+ [Benchmark]\r
+ public void Fast() => Thread.Sleep(50);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Columns;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Reports;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [ShortRunJob, Config(typeof(Config))]\r
+ public class IntroRatioStyle\r
+ {\r
+ [Benchmark(Baseline = true)]\r
+ public void Baseline() => Thread.Sleep(1000);\r
+\r
+ [Benchmark]\r
+ public void Bar() => Thread.Sleep(150);\r
+\r
+ [Benchmark]\r
+ public void Foo() => Thread.Sleep(1150);\r
+\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ SummaryStyle = SummaryStyle.Default.WithRatioStyle(RatioStyle.Trend);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroSetupCleanupGlobal\r
+ {\r
+ [Params(10, 100, 1000)]\r
+ public int N;\r
+\r
+ private int[] data;\r
+\r
+ [GlobalSetup]\r
+ public void GlobalSetup()\r
+ {\r
+ data = new int[N]; // executed once per each N value\r
+ }\r
+\r
+ [Benchmark]\r
+ public int Logic()\r
+ {\r
+ int res = 0;\r
+ for (int i = 0; i < N; i++)\r
+ res += data[i];\r
+ return res;\r
+ }\r
+\r
+ [GlobalCleanup]\r
+ public void GlobalCleanup()\r
+ {\r
+ // Disposing logic\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [SimpleJob(RunStrategy.Monitoring, launchCount: 1,\r
+ warmupCount: 2, iterationCount: 3)]\r
+ public class IntroSetupCleanupIteration\r
+ {\r
+ private int setupCounter;\r
+ private int cleanupCounter;\r
+\r
+ [IterationSetup]\r
+ public void IterationSetup()\r
+ => Console.WriteLine($"// IterationSetup ({++setupCounter})");\r
+\r
+ [IterationCleanup]\r
+ public void IterationCleanup()\r
+ => Console.WriteLine($"// IterationCleanup ({++cleanupCounter})");\r
+\r
+ [GlobalSetup]\r
+ public void GlobalSetup()\r
+ => Console.WriteLine("// " + "GlobalSetup");\r
+\r
+ [GlobalCleanup]\r
+ public void GlobalCleanup()\r
+ => Console.WriteLine("// " + "GlobalCleanup");\r
+\r
+ [Benchmark]\r
+ public void Benchmark()\r
+ => Console.WriteLine("// " + "Benchmark");\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Engines;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [SimpleJob(RunStrategy.Monitoring, launchCount: 0,\r
+ warmupCount: 0, iterationCount: 1)]\r
+ public class IntroSetupCleanupTarget\r
+ {\r
+ [GlobalSetup(Target = nameof(BenchmarkA))]\r
+ public void GlobalSetupA()\r
+ => Console.WriteLine("// " + "GlobalSetup A");\r
+\r
+ [Benchmark]\r
+ public void BenchmarkA()\r
+ => Console.WriteLine("// " + "Benchmark A");\r
+\r
+ [GlobalSetup(Targets = new[] { nameof(BenchmarkB), nameof(BenchmarkC) })]\r
+ public void GlobalSetupB()\r
+ => Console.WriteLine("// " + "GlobalSetup B");\r
+\r
+ [Benchmark]\r
+ public void BenchmarkB()\r
+ => Console.WriteLine("// " + "Benchmark B");\r
+\r
+ [Benchmark]\r
+ public void BenchmarkC()\r
+ => Console.WriteLine("// " + "Benchmark C");\r
+\r
+ [Benchmark]\r
+ public void BenchmarkD()\r
+ => Console.WriteLine("// " + "Benchmark D");\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class IntroStaThread\r
+ {\r
+ [Benchmark, System.STAThread]\r
+ public void CheckForSTA()\r
+ {\r
+ if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)\r
+ {\r
+ throw new ThreadStateException(\r
+ "The current threads apartment state is not STA");\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using Perfolizer.Mathematics.SignificanceTesting;\r
+using Perfolizer.Mathematics.Thresholds;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [StatisticalTestColumn(StatisticalTestKind.Welch, ThresholdUnit.Microseconds, 1, true)]\r
+ [StatisticalTestColumn(StatisticalTestKind.MannWhitney, ThresholdUnit.Microseconds, 1, true)]\r
+ [StatisticalTestColumn(StatisticalTestKind.Welch, ThresholdUnit.Ratio, 0.03, true)]\r
+ [StatisticalTestColumn(StatisticalTestKind.MannWhitney, ThresholdUnit.Ratio, 0.03, true)]\r
+ [SimpleJob(warmupCount: 0, iterationCount: 5)]\r
+ public class IntroStatisticalTesting\r
+ {\r
+ [Benchmark] public void Sleep50() => Thread.Sleep(50);\r
+ [Benchmark] public void Sleep97() => Thread.Sleep(97);\r
+ [Benchmark] public void Sleep99() => Thread.Sleep(99);\r
+ [Benchmark(Baseline = true)] public void Sleep100() => Thread.Sleep(100);\r
+ [Benchmark] public void Sleep101() => Thread.Sleep(101);\r
+ [Benchmark] public void Sleep103() => Thread.Sleep(103);\r
+ [Benchmark] public void Sleep150() => Thread.Sleep(150);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Security.Cryptography;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [MediumRunJob, SkewnessColumn, KurtosisColumn]\r
+ public class IntroStatisticsColumns\r
+ {\r
+ private const int N = 10000;\r
+ private readonly byte[] data;\r
+\r
+ private readonly MD5 md5 = MD5.Create();\r
+ private readonly SHA256 sha256 = SHA256.Create();\r
+\r
+ public IntroStatisticsColumns()\r
+ {\r
+ data = new byte[N];\r
+ new Random(42).NextBytes(data);\r
+ }\r
+\r
+ [Benchmark(Baseline = true)]\r
+ public byte[] Md5A() => md5.ComputeHash(data);\r
+\r
+ [Benchmark]\r
+ public byte[] Md5B() => md5.ComputeHash(data);\r
+\r
+ [Benchmark]\r
+ public byte[] Sha256() => sha256.ComputeHash(data);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [StopOnFirstError]\r
+ public class IntroStopOnFirstError\r
+ {\r
+ [Benchmark(Baseline = true)]\r
+ public int FirstMethod() => throw new Exception("Example exception.");\r
+\r
+ [Benchmark]\r
+ public int SecondMethod() => 1;\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Columns;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Jobs;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // You can add custom tags per each method using Columns\r
+ [Config(typeof(Config))]\r
+ public class IntroTagColumn\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config()\r
+ {\r
+ AddJob(Job.Dry);\r
+ AddColumn(new TagColumn("Kind", name => name.Substring(0, 3)));\r
+ AddColumn(new TagColumn("Number", name => name.Substring(3)));\r
+ }\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo1() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ public void Foo12() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ public void Bar3() => Thread.Sleep(10);\r
+\r
+ [Benchmark]\r
+ public void Bar34() => Thread.Sleep(10);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ [BenchmarkDotNet.Diagnostics.Windows.Configs.TailCallDiagnoser]\r
+ [LegacyJitX86Job, LegacyJitX64Job, RyuJitX64Job]\r
+ public class IntroTailcall\r
+ {\r
+ [Benchmark]\r
+ public long Calc()\r
+ => FactorialWithoutTailing(7) - FactorialWithTailing(7);\r
+\r
+ private static long FactorialWithoutTailing(int depth)\r
+ => depth == 0 ? 1 : depth * FactorialWithoutTailing(depth - 1);\r
+\r
+ private static long FactorialWithTailing(int pos, int depth)\r
+ => pos == 0 ? depth : FactorialWithTailing(pos - 1, depth * pos);\r
+\r
+ private static long FactorialWithTailing(int depth)\r
+ => FactorialWithTailing(depth - 1, depth);\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Running;\r
+using BenchmarkDotNet.Toolchains.DotNetCli;\r
+using BenchmarkDotNet.Toolchains.MonoWasm;\r
+using BenchmarkDotNet.Toolchains;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+using BenchmarkDotNet.Loggers;\r
+using System.Diagnostics;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // *** Attribute Style ***\r
+ [UnicodeConsoleLogger]\r
+ public class IntroUnicode\r
+ {\r
+ [Benchmark]\r
+ public long Foo()\r
+ {\r
+ long waitUntil = Stopwatch.GetTimestamp() + 1000;\r
+ while (Stopwatch.GetTimestamp() < waitUntil) { }\r
+ return waitUntil;\r
+ }\r
+ }\r
+\r
+ // *** Object Style ***\r
+ [Config(typeof(Config))]\r
+ public class IntroUnicodeObjectStyle\r
+ {\r
+ private class Config : ManualConfig\r
+ {\r
+ public Config() => AddLogger(ConsoleLogger.Unicode);\r
+ }\r
+\r
+ [Benchmark]\r
+ public long Foo()\r
+ {\r
+ long waitUntil = Stopwatch.GetTimestamp() + 1000;\r
+ while (Stopwatch.GetTimestamp() < waitUntil) { }\r
+ return waitUntil;\r
+ }\r
+ }\r
+\r
+ // *** Fluent Config ***\r
+ public class IntroUnicodeFluentConfig\r
+ {\r
+ public static void Run()\r
+ {\r
+ BenchmarkRunner.Run<IntroUnicodeFluentConfig>(\r
+ DefaultConfig.Instance\r
+ .AddLogger(ConsoleLogger.Unicode));\r
+ }\r
+\r
+ [Benchmark]\r
+ public long Foo()\r
+ {\r
+ long waitUntil = Stopwatch.GetTimestamp() + 1000;\r
+ while (Stopwatch.GetTimestamp() < waitUntil) { }\r
+ return waitUntil;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Attributes;\r
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Environments;\r
+using BenchmarkDotNet.Jobs;\r
+using BenchmarkDotNet.Loggers;\r
+using BenchmarkDotNet.Running;\r
+using BenchmarkDotNet.Toolchains.DotNetCli;\r
+using BenchmarkDotNet.Toolchains.MonoWasm;\r
+using BenchmarkDotNet.Toolchains;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Diagnostics;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ // *** Command Line Arguments ***\r
+ public class IntroWasmCmdConfig\r
+ {\r
+ // the args must contain:\r
+ // an information that we want to run benchmark as Wasm:\r
+ // --runtimes Wasm\r
+ // path to dotnet cli\r
+ // --cli /home/adam/projects/runtime/dotnet.sh\r
+ public static void Run(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(IntroWasmCmdConfig).Assembly).Run(args);\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+\r
+ // *** Fluent Config ***\r
+ public class IntroWasmFluentConfig\r
+ {\r
+ public static void Run()\r
+ {\r
+ // the Wasm Toolchain requires two mandatory arguments:\r
+ const string cliPath = @"/home/adam/projects/runtime/dotnet.sh";\r
+\r
+ WasmRuntime runtime = new WasmRuntime(msBuildMoniker: "net5.0");\r
+ NetCoreAppSettings netCoreAppSettings = new NetCoreAppSettings(\r
+ targetFrameworkMoniker: "net5.0", runtimeFrameworkVersion: null, name: "Wasm",\r
+ customDotNetCliPath: cliPath);\r
+ IToolchain toolChain = WasmToolchain.From(netCoreAppSettings);\r
+\r
+ BenchmarkRunner.Run<IntroCustomMonoFluentConfig>(DefaultConfig.Instance\r
+ .AddJob(Job.ShortRun.WithRuntime(runtime).WithToolchain(toolChain)));\r
+ }\r
+\r
+ [Benchmark]\r
+ public void Foo()\r
+ {\r
+ // Benchmark body\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using BenchmarkDotNet.Configs;\r
+using BenchmarkDotNet.Exporters;\r
+using BenchmarkDotNet.Loggers;\r
+using BenchmarkDotNet.Running;\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading.Tasks;\r
+\r
+namespace TizenBenchmark.Intro\r
+{\r
+ public class TizenDotnet\r
+ {\r
+ void IntroArguments()\r
+ {\r
+ Console.WriteLine("##### IntroArguments Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroArguments>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroArguments Benchmark END #####");\r
+ }\r
+ void IntroArgumentsSource()\r
+ {\r
+ Console.WriteLine("##### IntroArgumentsSource Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroArgumentsSource>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroArgumentsSource Benchmark END #####");\r
+ }\r
+ void IntroArrayParam()\r
+ {\r
+ Console.WriteLine("##### IntroArrayParam Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroArrayParam>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroArrayParam Benchmark END #####");\r
+ }\r
+ void IntroBasic()\r
+ {\r
+ Console.WriteLine("##### IntroBasic Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroBasic>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroBasic Benchmark END #####");\r
+ }\r
+ void IntroBenchmarkBaseline()\r
+ {\r
+ Console.WriteLine("##### IntroBenchmarkBaseline Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroBenchmarkBaseline>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroBenchmarkBaseline Benchmark END #####");\r
+ }\r
+ void IntroCategories()\r
+ {\r
+ Console.WriteLine("##### IntroCategories Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroCategories>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroCategories Benchmark END #####");\r
+ }\r
+ void IntroCategoryBaseline()\r
+ {\r
+ Console.WriteLine("##### IntroCategoryBaseline Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroCategoryBaseline>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroCategoryBaseline Benchmark END #####");\r
+ }\r
+ void IntroCategoryDiscoverer()\r
+ {\r
+ Console.WriteLine("##### IntroCategoryDiscoverer Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroCategoryDiscoverer>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroCategoryDiscoverer Benchmark END #####");\r
+ }\r
+ void IntroColdStart()\r
+ {\r
+ Console.WriteLine("##### IntroColdStart Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroColdStart>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroColdStart Benchmark END #####");\r
+ }\r
+ void IntroComparableComplexParam()\r
+ {\r
+ Console.WriteLine("##### IntroComparableComplexParam Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroComparableComplexParam>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroComparableComplexParam Benchmark END #####");\r
+ }\r
+ void IntroConfigSource()\r
+ {\r
+ Console.WriteLine("##### IntroConfigSource Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroConfigSource>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroConfigSource Benchmark END #####");\r
+ }\r
+ void IntroConfigUnion()\r
+ {\r
+ Console.WriteLine("##### IntroConfigUnion Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroConfigUnion>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroConfigUnion Benchmark END #####");\r
+ }\r
+ void IntroCustomMono()\r
+ {\r
+ Console.WriteLine("##### IntroCustomMono Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ //var summary = BenchmarkRunner.Run<IntroCustomMono>(config);\r
+ //MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ //Console.WriteLine(logger.GetLog());\r
+\r
+ //summary = BenchmarkRunner.Run<IntroCustomMonoObjectStyle>(config);\r
+ //MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ //Console.WriteLine(logger.GetLog());\r
+\r
+ //summary = BenchmarkRunner.Run<IntroCustomMonoObjectStyleAot>(config);\r
+ //MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ //Console.WriteLine(logger.GetLog());\r
+\r
+ var summary = BenchmarkRunner.Run<IntroCustomMonoFluentConfig>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroCustomMono Benchmark END #####");\r
+ }\r
+ void IntroCustomMonoArguments()\r
+ {\r
+ Console.WriteLine("##### IntroCustomMonoArguments Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroCustomMonoArguments>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroCustomMonoArguments Benchmark END #####");\r
+ }\r
+ void IntroDeferredExecution()\r
+ {\r
+ Console.WriteLine("##### IntroDeferredExecution Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDeferredExecution>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDeferredExecution Benchmark END #####");\r
+ }\r
+ void IntroDisassembly()\r
+ {\r
+ Console.WriteLine("##### IntroDisassembly Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDisassembly>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDisassembly Benchmark END #####");\r
+ }\r
+ void IntroDisassemblyAllJits()\r
+ {\r
+ Console.WriteLine("##### IntroDisassemblyAllJits Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDisassemblyAllJits>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDisassemblyAllJits Benchmark END #####");\r
+ }\r
+ void IntroDisassemblyDry()\r
+ {\r
+ Console.WriteLine("##### IntroDisassemblyDry Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDisassemblyDry>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDisassemblyDry Benchmark END #####");\r
+ }\r
+ void IntroDisassemblyRyuJit()\r
+ {\r
+ Console.WriteLine("##### IntroDisassemblyRyuJit Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDisassemblyRyuJit>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDisassemblyRyuJit Benchmark END #####");\r
+ }\r
+ void IntroDotTraceDiagnoser()\r
+ {\r
+ Console.WriteLine("##### IntroDotTraceDiagnoser Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroDotTraceDiagnoser>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroDotTraceDiagnoser Benchmark END #####");\r
+ }\r
+ void IntroEnvVars()\r
+ {\r
+ Console.WriteLine("##### IntroEnvVars Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroEnvVars>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroEnvVars Benchmark END #####");\r
+ }\r
+ void IntroEventPipeProfiler()\r
+ {\r
+ Console.WriteLine("##### IntroEventPipeProfiler Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroEventPipeProfiler>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroEventPipeProfiler Benchmark END #####");\r
+ }\r
+ void IntroEventPipeProfilerAdvanced()\r
+ {\r
+ Console.WriteLine("##### IntroEventPipeProfilerAdvanced Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroEventPipeProfilerAdvanced>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroEventPipeProfilerAdvanced Benchmark END #####");\r
+ }\r
+ void IntroExport()\r
+ {\r
+ Console.WriteLine("##### IntroExport Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroExport>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroExport Benchmark END #####");\r
+ }\r
+ void IntroExportJson()\r
+ {\r
+ Console.WriteLine("##### IntroExportJson Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroExportJson>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroExportJson Benchmark END #####");\r
+ }\r
+ void IntroExportXml()\r
+ {\r
+ Console.WriteLine("##### IntroExportXml Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroExportXml>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroExportXml Benchmark END #####");\r
+ }\r
+ void IntroFilters()\r
+ {\r
+ Console.WriteLine("##### IntroFilters Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroFilters>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroFilters Benchmark END #####");\r
+ }\r
+ void IntroFluentConfigBuilder()\r
+ {\r
+ Console.WriteLine("##### IntroFluentConfigBuilder Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroFluentConfigBuilder>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroFluentConfigBuilder Benchmark END #####");\r
+ }\r
+ void IntroGcMode()\r
+ {\r
+ Console.WriteLine("##### IntroGcMode Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroGcMode>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroGcMode Benchmark END #####");\r
+ }\r
+ void IntroGenericTypeArguments()\r
+ {\r
+ Console.WriteLine("##### IntroGenericTypeArguments Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroGenericTypeArguments<int>>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+\r
+ summary = BenchmarkRunner.Run<IntroGenericTypeArguments<char>>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroGenericTypeArguments Benchmark END #####");\r
+ }\r
+ void IntroHardwareCounters()\r
+ {\r
+ Console.WriteLine("##### IntroHardwareCounters Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroHardwareCounters>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroHardwareCounters Benchmark END #####");\r
+ }\r
+ void IntroInliningDiagnoser()\r
+ {\r
+ Console.WriteLine("##### IntroInliningDiagnoser Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroInliningDiagnoser>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroInliningDiagnoser Benchmark END #####");\r
+ }\r
+ void IntroInProcess()\r
+ {\r
+ Console.WriteLine("##### IntroInProcess Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroInProcess>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroInProcess Benchmark END #####");\r
+ }\r
+ void IntroInProcessWrongEnv()\r
+ {\r
+ Console.WriteLine("##### IntroInProcessWrongEnv Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroInProcessWrongEnv>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroInProcessWrongEnv Benchmark END #####");\r
+ }\r
+ void IntroJitStatsDiagnoser()\r
+ {\r
+ Console.WriteLine("##### IntroJitStatsDiagnoser Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroJitStatsDiagnoser>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroJitStatsDiagnoser Benchmark END #####");\r
+ }\r
+ void IntroJobBaseline()\r
+ {\r
+ Console.WriteLine("##### IntroJobBaseline Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroJobBaseline>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroJobBaseline Benchmark END #####");\r
+ }\r
+ void IntroJoin()\r
+ {\r
+ Console.WriteLine("##### IntroJoin Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroJoin1>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+\r
+ summary = BenchmarkRunner.Run<IntroJoin2>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroJoin Benchmark END #####");\r
+ }\r
+ void IntroLargeAddressAware()\r
+ {\r
+ Console.WriteLine("##### IntroLargeAddressAware Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroLargeAddressAware>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroLargeAddressAware Benchmark END #####");\r
+ }\r
+ void IntroMonitoring()\r
+ {\r
+ Console.WriteLine("##### IntroMonitoring Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroMonitoring>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroMonitoring Benchmark END #####");\r
+ }\r
+ void IntroMultimodal()\r
+ {\r
+ Console.WriteLine("##### IntroMultimodal Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroMultimodal>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroMultimodal Benchmark END #####");\r
+ }\r
+ void IntroNativeMemory()\r
+ {\r
+ Console.WriteLine("##### IntroNativeMemory Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroNativeMemory>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroNativeMemory Benchmark END #####");\r
+ }\r
+ void IntroNuGet()\r
+ {\r
+ Console.WriteLine("##### IntroNuGet Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroNuGet>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroNuGet Benchmark END #####");\r
+ }\r
+ void IntroOrderAttr()\r
+ {\r
+ Console.WriteLine("##### IntroOrderAttr Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroOrderAttr>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroOrderAttr Benchmark END #####");\r
+ }\r
+ void IntroOrderManual()\r
+ {\r
+ Console.WriteLine("##### IntroOrderManual Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroOrderManual>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroOrderManual Benchmark END #####");\r
+ }\r
+ void IntroOutliers()\r
+ {\r
+ Console.WriteLine("##### IntroOutliers Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroOutliers>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroOutliers Benchmark END #####");\r
+ }\r
+ void IntroParams()\r
+ {\r
+ Console.WriteLine("##### IntroParams Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroParams>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroParams Benchmark END #####");\r
+ }\r
+ void IntroParamsAllValues()\r
+ {\r
+ Console.WriteLine("##### IntroParamsAllValues Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroParamsAllValues>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroParamsAllValues Benchmark END #####");\r
+ }\r
+ void IntroParamsSource()\r
+ {\r
+ Console.WriteLine("##### aIntroParamsSourceaa Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroParamsSource>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroParamsSource Benchmark END #####");\r
+ }\r
+ void IntroPercentiles()\r
+ {\r
+ Console.WriteLine("##### IntroPercentiles Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroPercentiles>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroPercentiles Benchmark END #####");\r
+ }\r
+ void IntroPowerPlan()\r
+ {\r
+ Console.WriteLine("##### IntroPowerPlan Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroPowerPlan>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroPowerPlan Benchmark END #####");\r
+ }\r
+ void IntroRankColumn()\r
+ {\r
+ Console.WriteLine("##### IntroRankColumn Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroRankColumn>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroRankColumn Benchmark END #####");\r
+ }\r
+ void IntroRatioSD()\r
+ {\r
+ Console.WriteLine("##### IntroRatioSD Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroRatioSD>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroRatioSD Benchmark END #####");\r
+ }\r
+ void IntroRatioStyle()\r
+ {\r
+ Console.WriteLine("##### IntroRatioStyle Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroRatioStyle>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroRatioStyle Benchmark END #####");\r
+ }\r
+ void IntroSetupCleanupGlobal()\r
+ {\r
+ Console.WriteLine("##### IntroSetupCleanupGlobal Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroSetupCleanupGlobal>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroSetupCleanupGlobal Benchmark END #####");\r
+ }\r
+ void IntroSetupCleanupIteration()\r
+ {\r
+ Console.WriteLine("##### IntroSetupCleanupIteration Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroSetupCleanupIteration>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroSetupCleanupIteration Benchmark END #####");\r
+ }\r
+ void IntroSetupCleanupTarget()\r
+ {\r
+ Console.WriteLine("##### IntroSetupCleanupTarget Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroSetupCleanupTarget>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroSetupCleanupTarget Benchmark END #####");\r
+ }\r
+ void IntroStaThread()\r
+ {\r
+ Console.WriteLine("##### IntroStaThread Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroStaThread>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroStaThread Benchmark END #####");\r
+ }\r
+ void IntroStatisticalTesting()\r
+ {\r
+ Console.WriteLine("##### IntroStatisticalTesting Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroStatisticalTesting>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroStatisticalTesting Benchmark END #####");\r
+ }\r
+ void IntroStatisticsColumns()\r
+ {\r
+ Console.WriteLine("##### IntroStatisticsColumns Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroStatisticsColumns>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroStatisticsColumns Benchmark END #####");\r
+ }\r
+ void IntroStopOnFirstError()\r
+ {\r
+ Console.WriteLine("##### IntroStopOnFirstError Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroStopOnFirstError>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroStopOnFirstError Benchmark END #####");\r
+ }\r
+ void IntroTagColumn()\r
+ {\r
+ Console.WriteLine("##### IntroTagColumn Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroTagColumn>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroTagColumn Benchmark END #####");\r
+ }\r
+ void IntroTailcall()\r
+ {\r
+ Console.WriteLine("##### IntroTailcall Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroTailcall>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroTailcall Benchmark END #####");\r
+ }\r
+ void IntroUnicode()\r
+ {\r
+ Console.WriteLine("##### IntroUnicode Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroUnicode>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+\r
+ summary = BenchmarkRunner.Run<IntroUnicodeObjectStyle>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+\r
+ summary = BenchmarkRunner.Run<IntroUnicodeFluentConfig>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroUnicode Benchmark END #####");\r
+ }\r
+ void IntroWasm()\r
+ {\r
+ Console.WriteLine("##### IntroWasm Benchmark START #####");\r
+ var logger = new AccumulationLogger();\r
+ var config = default(IConfig);\r
+ config = new DebugInProcessConfig();\r
+ config = config.WithArtifactsPath("/tmp/BenchmarkDotnet");\r
+\r
+ var summary = BenchmarkRunner.Run<IntroWasmCmdConfig>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+\r
+ summary = BenchmarkRunner.Run<IntroWasmFluentConfig>(config);\r
+ MarkdownExporter.Console.ExportToLog(summary, logger);\r
+ Console.WriteLine(logger.GetLog());\r
+ Console.WriteLine("##### IntroWasm Benchmark END #####");\r
+ }\r
+\r
+\r
+ public void Benchmark()\r
+ {\r
+ Console.WriteLine("##### Tizen.NET Benchmark START #####");\r
+ IntroArguments(); //1\r
+ IntroArgumentsSource(); //1\r
+ IntroArrayParam(); //1\r
+ IntroBasic(); //1\r
+ IntroBenchmarkBaseline(); //1\r
+ //IntroCategories();\r
+ IntroCategoryBaseline(); //1\r
+ //IntroCategoryDiscoverer();\r
+ //IntroColdStart();\r
+ IntroComparableComplexParam(); //1\r
+ //IntroConfigSource();\r
+ //IntroConfigUnion();\r
+ IntroCustomMono(); //1\r
+ //IntroCustomMonoArguments();\r
+ IntroDeferredExecution(); //1\r
+ //IntroDisassembly();\r
+ //IntroDisassemblyAllJits();\r
+ //IntroDisassemblyDry();\r
+ //IntroDisassemblyRyuJit();\r
+ //IntroDotTraceDiagnoser();\r
+ //IntroEnvVars();\r
+ //IntroEventPipeProfiler();\r
+ //IntroEventPipeProfilerAdvanced();\r
+ //IntroExport();\r
+ //IntroExportJson();\r
+ //IntroExportXml();\r
+ //IntroFilters();\r
+ //IntroFluentConfigBuilder();\r
+ //IntroGcMode();\r
+ IntroGenericTypeArguments(); //2\r
+ IntroHardwareCounters(); //1\r
+ //IntroInliningDiagnoser();\r
+ //IntroInProcess();\r
+ IntroInProcessWrongEnv(); //1\r
+ //IntroJitStatsDiagnoser();\r
+ //IntroJobBaseline();\r
+ //IntroJoin();\r
+ //IntroLargeAddressAware();\r
+ //IntroMonitoring();\r
+ //IntroMultimodal();\r
+ //IntroNativeMemory();\r
+ //IntroNuGet();\r
+ //IntroOrderAttr();\r
+ //IntroOrderManual();\r
+ //IntroOutliers();\r
+ IntroParams(); //1\r
+ //IntroParamsAllValues();\r
+ IntroParamsSource(); //1\r
+ //IntroPercentiles();\r
+ //IntroPowerPlan();\r
+ //IntroRankColumn();\r
+ //IntroRatioSD();\r
+ //IntroRatioStyle();\r
+ IntroSetupCleanupGlobal(); //1\r
+ //IntroSetupCleanupIteration();\r
+ //IntroSetupCleanupTarget();\r
+ IntroStaThread(); //1\r
+ //IntroStatisticalTesting();\r
+ //IntroStatisticsColumns();\r
+ //IntroStopOnFirstError();\r
+ //IntroTagColumn();\r
+ //IntroTailcall();\r
+ IntroUnicode(); //3\r
+ IntroWasm(); //2\r
+ Console.WriteLine("##### Tizen.NET Benchmark END #####");\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+\r
+namespace TizenBenchmark\r
+{\r
+ class Program : NUIApplication\r
+ {\r
+ protected override void OnCreate()\r
+ {\r
+ base.OnCreate();\r
+ Initialize();\r
+ }\r
+\r
+ void Initialize()\r
+ {\r
+ Intro.TizenDotnet benchmark = new Intro.TizenDotnet();\r
+ benchmark.Benchmark();\r
+\r
+ Window.Instance.KeyEvent += OnKeyEvent;\r
+\r
+ TextLabel text = new TextLabel("Hello Tizen NUI World");\r
+ text.HorizontalAlignment = HorizontalAlignment.Center;\r
+ text.VerticalAlignment = VerticalAlignment.Center;\r
+ text.TextColor = Color.Blue;\r
+ text.PointSize = 12.0f;\r
+ text.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+ text.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+ Window.Instance.GetDefaultLayer().Add(text);\r
+\r
+ Animation animation = new Animation(2000);\r
+ animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);\r
+ animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);\r
+ animation.Looping = true;\r
+ animation.Play();\r
+ }\r
+\r
+ public void OnKeyEvent(object sender, Window.KeyEventArgs e)\r
+ {\r
+ if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))\r
+ {\r
+ Exit();\r
+ }\r
+ }\r
+\r
+ static void Main(string[] args)\r
+ {\r
+ var app = new Program();\r
+ app.Run(args);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">\r
+\r
+ <PropertyGroup>\r
+ <OutputType>Exe</OutputType>\r
+ <TargetFramework>net6.0-tizen</TargetFramework>\r
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+ </PropertyGroup>\r
+\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugType>portable</DebugType>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>None</DebugType>\r
+ </PropertyGroup>\r
+\r
+ <ItemGroup>\r
+ <Folder Include="lib\" />\r
+ <Folder Include="res\" />\r
+ </ItemGroup>\r
+\r
+ <ItemGroup>\r
+ <PackageReference Include="BenchmarkDotNet" Version="0.13.12" />\r
+ <PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.12" />\r
+ <PackageReference Include="BenchmarkDotNet.Diagnostics.dotTrace" Version="0.13.12" />\r
+ <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.12" />\r
+ <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />\r
+ <PackageReference Include="System.Drawing.Common" Version="8.0.0" />\r
+ </ItemGroup>\r
+\r
+</Project>\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="8.0" package="org.tizen.dotnet.TizenBenchmark" version="1.0.0">
+ <profile name="common" />
+ <ui-application appid="org.tizen.dotnet.TizenBenchmark"
+ exec="TizenBenchmark.dll"
+ type="dotnet"
+ multiple="false"
+ taskmanage="true"
+ nodisplay="false"
+ launch_mode="single"
+ api-version="11">
+ <label>TizenBenchmark</label>
+ <icon>TizenBenchmark.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ </ui-application>
+</manifest>
--- /dev/null
+# csproj file path
+csproj_file: TizenBenchmark.csproj
+
+# files monitored for dirty/modified status
+files:
+ - TizenBenchmark.csproj
+ - TizenBenchmark.cs
+ - tizen-manifest.xml
+ - shared/res/TizenBenchmark.png
\ No newline at end of file