This commit is contained in:
Elie Bariche 2022-01-25 03:12:52 -05:00
Родитель 472c09ca85
Коммит a78bd4d89f
30 изменённых файлов: 958 добавлений и 18 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -328,3 +328,6 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# PackageCache
!src/Benchmarks/PackageCache/*.nupkg

Просмотреть файл

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>D3FEBE61-3355-48DC-97D5-EFA61AF936B1</ProjectGuid>
<ProjectGuid>{D3FEBE61-3355-48DC-97D5-EFA61AF936B1}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
@ -56,10 +56,17 @@
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Uno.BenchmarkDotNet">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.BenchmarkDotNet.Annotations">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.UI" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />

Просмотреть файл

@ -0,0 +1,58 @@
<UserControl x:Class="Benchmarks.Shared.Controls.BenchmarkDotNetControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Benchmarks.Shared.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Name="benchmarkControl"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBox PlaceholderText="Class name contains..."
Width="400"
Text="{x:Bind ClassFilter, Mode=TwoWay}"
HorizontalAlignment="Left" />
<Button x:Name="runButton"
Content="Run Benchmarks"
Click="OnRunTests" />
<TextBlock x:Name="runCount"
Text="" />
<TextBlock x:Name="runStatus"
Text="Not initialized" />
<CheckBox x:Name="debugLog"
IsChecked="False"
Content="Debug Logging" />
<Button x:Name="downloadResults"
Content="Download Results"
IsEnabled="false"
Click="{x:Bind OnDownloadResults}" />
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ScrollViewer Grid.Column="0"
Background="Black"
HorizontalScrollMode="Enabled"
HorizontalScrollBarVisibility="Visible"
Padding="12">
<TextBlock x:Name="runLogs"
Grid.Column="1"
FontFamily="Courier New"
FontSize="12"
IsTextSelectionEnabled="True" />
</ScrollViewer>
<ContentControl x:Name="testHost" />
</Grid>
</Grid>
</Grid>
</UserControl>

Просмотреть файл

@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Exporters.Json;
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.InProcess;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Provider;
using Windows.UI;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace Benchmarks.Shared.Controls
{
public sealed partial class BenchmarkDotNetControl : UserControl
{
private const string BenchmarksBaseNamespace = "SamplesApp.Benchmarks.Suite";
private TextBlockLogger _logger;
public BenchmarkDotNetControl()
{
this.InitializeComponent();
}
public string ResultsAsBase64
{
get => (string)GetValue(ResultsAsBase64Property);
set => SetValue(ResultsAsBase64Property, value);
}
public static readonly DependencyProperty ResultsAsBase64Property =
DependencyProperty.Register("ResultsAsBase64", typeof(string), typeof(BenchmarkDotNetControl), new PropertyMetadata(""));
public string ClassFilter { get; set; } = "";
private void OnRunTests(object sender, object args)
{
_ = Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async () => await Run()
);
}
private async Task Run()
{
_logger = new TextBlockLogger(runLogs, debugLog.IsChecked ?? false);
try
{
var config = new CoreConfig(_logger);
BenchmarkUIHost.Root = FindName("testHost") as ContentControl;
await SetStatus("Discovering benchmarks in " + BenchmarksBaseNamespace);
var types = EnumerateBenchmarks(config).ToArray();
int currentCount = 0;
foreach (var type in types)
{
runCount.Text = (++currentCount).ToString();
await SetStatus($"Running benchmarks for {type}");
var b = BenchmarkRunner.Run(type, config);
for (int i = 0; i < 3; i++)
{
await Dispatcher.RunIdleAsync(_ =>
{
GC.Collect();
GC.WaitForPendingFinalizers();
});
}
}
await SetStatus($"Finished");
ArchiveTestResult(config);
}
catch (Exception e)
{
await SetStatus($"Failed {e?.Message}");
_logger.WriteLine(LogKind.Error, e?.ToString());
}
finally
{
BenchmarkUIHost.Root = null;
}
}
private void ArchiveTestResult(CoreConfig config)
{
var archiveName = BenchmarkResultArchiveName;
if (File.Exists(archiveName))
{
File.Delete(archiveName);
}
ZipFile.CreateFromDirectory(config.ArtifactsPath, archiveName, CompressionLevel.Optimal, false);
downloadResults.IsEnabled = true;
ResultsAsBase64 = Convert.ToBase64String(File.ReadAllBytes(BenchmarkResultArchiveName));
}
private static string BenchmarkResultArchiveName
=> Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "benchmarks-results.zip");
private async void OnDownloadResults()
{
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Zip Archive", new List<string>() { ".zip" });
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "benchmarks-results";
var file = await savePicker.PickSaveFileAsync();
if (file != null)
{
CachedFileManager.DeferUpdates(file);
await FileIO.WriteBytesAsync(file, File.ReadAllBytes(BenchmarkResultArchiveName));
await CachedFileManager.CompleteUpdatesAsync(file);
}
}
private async Task SetStatus(string status)
{
runStatus.Text = status;
await Task.Yield();
}
private IEnumerable<Type> EnumerateBenchmarks(IConfig config)
=> from type in GetType().GetTypeInfo().Assembly.GetTypes()
where !type.IsGenericType
where type.Namespace?.StartsWith(BenchmarksBaseNamespace) ?? false
where BenchmarkConverter.TypeToBenchmarks(type, config).BenchmarksCases.Length != 0
where string.IsNullOrEmpty(ClassFilter)
|| type.Name.IndexOf(ClassFilter, StringComparison.InvariantCultureIgnoreCase) >= 0
select type;
public class CoreConfig : ManualConfig
{
public CoreConfig(ILogger logger)
{
Add(logger);
Add(AsciiDocExporter.Default);
Add(JsonExporter.Full);
Add(CsvExporter.Default);
Add(BenchmarkDotNet.Exporters.Xml.XmlExporter.Full);
Add(Job.InProcess
.WithLaunchCount(1)
.WithWarmupCount(1)
.WithIterationCount(5)
.WithIterationTime(TimeInterval.FromMilliseconds(100))
#if __IOS__
// Fails on iOS with code generation used by EmitInvokeMultiple
.WithUnrollFactor(1)
#endif
.With(InProcessToolchain.Synchronous)
.WithId("InProcess")
);
ArtifactsPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "benchmarks");
}
}
private class TextBlockLogger : ILogger
{
private static Dictionary<LogKind, SolidColorBrush> ColorfulScheme { get; } =
new Dictionary<LogKind, SolidColorBrush>
{
{ LogKind.Default, new SolidColorBrush(Colors.Gray) },
{ LogKind.Help, new SolidColorBrush(Colors.DarkGreen) },
{ LogKind.Header, new SolidColorBrush(Colors.Magenta) },
{ LogKind.Result, new SolidColorBrush(Colors.DarkCyan) },
{ LogKind.Statistic, new SolidColorBrush(Colors.Cyan) },
{ LogKind.Info, new SolidColorBrush(Colors.DarkOrange) },
{ LogKind.Error, new SolidColorBrush(Colors.Red) },
{ LogKind.Hint, new SolidColorBrush(Colors.DarkCyan) }
};
private readonly TextBlock _target;
private LogKind _minLogKind;
public TextBlockLogger(TextBlock target, bool isDebug)
{
_target = target;
_minLogKind = isDebug ? LogKind.Default : LogKind.Statistic;
}
public void Flush() { }
public void Write(LogKind logKind, string text)
{
if (logKind >= _minLogKind)
{
_target.Inlines.Add(new Run { Text = text, Foreground = GetLogKindColor(logKind) });
}
}
public static Brush GetLogKindColor(LogKind logKind)
{
if (!ColorfulScheme.TryGetValue(logKind, out var brush))
{
brush = ColorfulScheme[LogKind.Default];
}
return brush;
}
public void WriteLine() => _target.Inlines.Add(new LineBreak());
public void WriteLine(LogKind logKind, string text)
{
if (logKind >= _minLogKind)
{
Write(logKind, text);
WriteLine();
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,9 @@
using Windows.UI.Xaml.Controls;
namespace Benchmarks.Shared.Controls
{
internal class BenchmarkUIHost
{
public static ContentControl Root { get; internal set; }
}
}

Просмотреть файл

@ -2,13 +2,13 @@
x:Class="Benchmarks.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Benchmarks"
xmlns:controls="using:Benchmarks.Shared.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<TextBlock Text="Hello, world!" Margin="20" FontSize="30" />
<controls:BenchmarkDotNetControl />
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BenchmarkDotNet.Attributes;
namespace SamplesApp.Benchmarks.Suite.SpanBench
{
public class SpanTesting
{
[Params(10, 20)]
public int Items { get; set; }
[Benchmark(Baseline = true)]
public void EnumerableSum()
{
var r = Enumerable.Range(0, Items).ToArray();
var s = r.Sum();
}
[Benchmark()]
public void SpanSum()
{
var r = Enumerable.Range(0, Items).ToArray();
var s = ((Span<int>)r).Sum();
}
}
public static class Extensions
{
public static double Sum(this Span<int> span)
{
double result = 0;
foreach (var value in span)
{
result += value;
}
return result;
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Microsoft.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml.ResourceDictionaryBench
{
public class XamlControlsResourcesCreationBenchmark
{
[Benchmark]
public void Create_XamlControlsResources()
{
var xcr = new XamlControlsResources();
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
#pragma warning disable 105 // Disabled until the tree is migrate to WinUI
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BenchmarkDotNet.Attributes;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml.ResourceDictionaryBench
{
public class XamlControlsResourcesCreationRetrievalBenchmark
{
[Benchmark]
public void Create_XamlControlsResources_And_Retrieve_Style()
{
var xcr = new XamlControlsResources();
var style = xcr["ListViewItemExpanded"] as Style;
var templateSetter = style.Setters.OfType<Setter>().First(s => s.Property == Control.TemplateProperty);
var template = templateSetter.Value;
}
}
}

Просмотреть файл

@ -0,0 +1,46 @@
#pragma warning disable 105 // Disabled until the tree is migrate to WinUI
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BenchmarkDotNet.Attributes;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml.ResourceDictionaryBench
{
public class XamlControlsResourcesReadBenchmark
{
XamlControlsResources SUT;
[GlobalSetup]
public void Setup()
{
SUT = new XamlControlsResources();
if (!(SUT["ListViewItemExpanded"] is Style)) {
throw new InvalidOperationException($"ListViewItemExpanded does not exist");
}
}
[Benchmark]
public void ReadInvalidKey()
{
SUT.TryGetValue("InvalidKey", out var style);
}
[Benchmark]
public void ReadExistingKey()
{
SUT.TryGetValue("ListViewItemExpanded", out var style);
}
[Benchmark]
public void ReadExistingType()
{
SUT.TryGetValue(typeof(Frame), out var style);
}
}
}

Просмотреть файл

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.BorderBench
{
public class BorderBenchmark
{
private Border SUT;
private SolidColorBrush MyBrush;
[GlobalSetup]
public void Setup()
{
SUT = new Border();
MyBrush = new SolidColorBrush();
}
[Benchmark()]
public void Toggle_BorderBrush()
{
SUT.BorderBrush = MyBrush;
SUT.BorderBrush = null;
}
[Benchmark()]
public void Toggle_Style()
{
SUT.Style = new Windows.UI.Xaml.Style();
SUT.ClearValue(Border.StyleProperty);
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Benchmarks.Shared.Controls;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.DependencyPropertyBench
{
public class PropagationDPBenchmark
{
private ContentControl SUT;
private int _updateCount;
[GlobalSetup]
public void Setup()
{
SUT = new ContentControl();
SUT.Content = new ContentControl();
BenchmarkUIHost.Root.Content = SUT;
}
[Benchmark()]
public void UpdateInheritedProperty()
{
SUT.FontSize = (_updateCount++ % 2) == 0 ? 21 : 42;
}
[Benchmark()]
public void UpdateNonInheritedProperty()
{
SUT.Tag = (_updateCount++ % 2) == 0 ? 21 : 42;
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.GridBench
{
public class SimpleDPBenchmark
{
private Grid SUT;
[GlobalSetup]
public void Setup()
{
SUT = new Grid();
}
[Benchmark()]
public void DP_Write()
{
for (int i = 0; i < 100; i++)
{
SUT.Width = i;
}
}
[Benchmark()]
public void DP_Read()
{
for (int i = 0; i < 100; i++)
{
var r = SUT.Width;
}
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.DependencyPropertyBench
{
public class SpecializedDPBenchmark
{
[GlobalSetup]
public void Setup()
{
}
[Benchmark()]
public void Property_GetMetadataNotSelf()
{
Border.TagProperty.GetMetadata(typeof(Border));
}
}
}

Просмотреть файл

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.FrameworkElementBench
{
public class FrameworkElementBenchmark
{
private Border SUT;
[GlobalSetup]
public void Setup()
{
SUT = new Border();
}
[Benchmark()]
public void Toggle_Style()
{
SUT.Style = new Windows.UI.Xaml.Style();
SUT.ClearValue(Border.StyleProperty);
}
}
}

Просмотреть файл

@ -0,0 +1,129 @@
using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using BenchmarkDotNet.Engines;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.GridBench
{
public class SimpleGridBenchmark
{
private Grid _sut;
[Params(0, 1, 5)]
public int ItemsCount { get; set; }
[IterationSetup]
public void Setup()
{
_sut = new Grid();
for (var i = 0; i < ItemsCount; i++)
{
_sut.Children.Add(new Border { Width = 10, Height = 10 });
}
}
[IterationCleanup]
public void Cleanup()
{
_sut = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
[Benchmark(Baseline = true)]
public void Superposition_Measure()
{
_sut.Measure(new Size(20, 20));
}
[Benchmark]
public void Superposition_Measure_And_Arrange()
{
_sut.Measure(new Size(20, 20));
_sut.Arrange(new Rect(0, 0, 20, 20));
}
[Benchmark]
public void Complex_Measure_And_Arrange_Pixels()
{
Complex_Measure_And_Arrange(new GridLength(10));
}
[Benchmark]
public void Complex_Measure_And_Arrange_Auto()
{
Complex_Measure_And_Arrange(new GridLength(0, GridUnitType.Auto));
}
[Benchmark]
public void Complex_Measure_And_Arrange_Star()
{
Complex_Measure_And_Arrange(new GridLength(1, GridUnitType.Star));
}
private void Complex_Measure_And_Arrange(GridLength gridLength)
{
var children = _sut.Children;
for (var i = 0; i < ItemsCount; i++)
{
var colDef = new ColumnDefinition { Width = gridLength };
_sut.ColumnDefinitions.Add(colDef);
var border = children[i] as FrameworkElement;
Grid.SetColumn(border, i);
}
_sut.Measure(new Size(500, 500));
_sut.Arrange(new Rect(0, 0, 500, 500));
}
[Benchmark]
public void Complex_MultiDimension_Measure_And_Arrange_Pixels()
{
Complex_MultiDimension_Measure_And_Arrange(new GridLength(10));
}
[Benchmark]
public void Complex_MultiDimension_Measure_And_Arrange_Auto()
{
Complex_MultiDimension_Measure_And_Arrange(new GridLength(0, GridUnitType.Auto));
}
[Benchmark]
public void Complex_MultiDimension_Measure_And_Arrange_Star()
{
Complex_MultiDimension_Measure_And_Arrange(new GridLength(1, GridUnitType.Star));
}
private void Complex_MultiDimension_Measure_And_Arrange(GridLength gridLength)
{
var children = _sut.Children;
for (var i = 0; i < ItemsCount; i++)
{
var colDef = new ColumnDefinition { Width = gridLength };
_sut.ColumnDefinitions.Add(colDef);
var rowDef = new RowDefinition { Height = gridLength };
_sut.RowDefinitions.Add(rowDef);
var border = children[i] as FrameworkElement;
Grid.SetColumn(border, i);
Grid.SetColumnSpan(border, i % 4 + 1);
Grid.SetRow(border, i);
Grid.SetRowSpan(border, i % 3 + 1);
}
_sut.Measure(new Size(2000, 2000));
_sut.Arrange(new Rect(0, 0, 2000, 2000));
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Benchmarks.Shared.Controls;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.GridBench
{
public class ControlCreationBenchmark
{
[Benchmark()]
public void TextBoxCreation()
=> BenchmarkUIHost.Root.Content = new TextBox();
[Benchmark()]
public void ButtonCreation()
=> BenchmarkUIHost.Root.Content = new Button();
[Benchmark()]
public void CheckBoxCreation()
=> BenchmarkUIHost.Root.Content = new CheckBox();
[Benchmark()]
public void TextBlockCreation()
=> BenchmarkUIHost.Root.Content = new TextBlock();
[Benchmark()]
public void SplitViewCreation()
=> BenchmarkUIHost.Root.Content = new SplitView();
[Benchmark()]
public void ScrollViewerCreation()
=> BenchmarkUIHost.Root.Content = new ScrollViewer();
[Benchmark()]
public void NavigationViewCreation()
=> BenchmarkUIHost.Root.Content = new NavigationView();
[Benchmark()]
public void ScrollBarCreation()
=> BenchmarkUIHost.Root.Content = new ScrollBar();
[Benchmark()]
public void ListViewItemCreation()
=> BenchmarkUIHost.Root.Content = new ListViewItem();
[Benchmark()]
public void ComboBoxCreation()
=> BenchmarkUIHost.Root.Content = new ComboBox();
[Benchmark()]
public void ComboBoxItemCreation()
=> BenchmarkUIHost.Root.Content = new ComboBoxItem();
[GlobalCleanup]
public void Setup()
{
BenchmarkUIHost.Root.Content = null;
}
}
}

Просмотреть файл

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Benchmarks.Shared.Controls;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.GridBench
{
public class LoadUnloadBenchmark
{
[Params(5, 10, 30)]
public int Depth { get; set; }
private Grid SUT;
[GlobalSetup]
public void Setup()
{
SUT = CreateHierachy();
}
[Benchmark()]
public void BasicLoadUnload()
{
var item = CreateHierachy();
for (int i = 0; i < 50; i++)
{
BenchmarkUIHost.Root.Content = item;
BenchmarkUIHost.Root.Content = null;
}
}
private Grid CreateHierachy()
{
var top = new Grid();
var current = top;
for (int i = 0; i < Depth; i++)
{
var n = new Grid();
current.Children.Add(n);
current = n;
}
current.Children.Add(new TextBlock() { Text = "test" });
return top;
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Shapes;
namespace SamplesApp.Benchmarks.Suite.Windows_UI_Xaml_Controls.UIElementPerf
{
public class UIElementCreationBenchmark
{
[Benchmark]
public void BorderCreation()
{
var SUT = new Grid();
for (int i = 0; i < 20; i++)
{
SUT.Children.Add(new Border());
}
}
[Benchmark]
public void RectangleCreation()
{
var SUT = new Grid();
for (int i = 0; i < 20; i++)
{
SUT.Children.Add(new Rectangle());
}
}
}
}

Просмотреть файл

@ -15,6 +15,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Uno.BenchmarkDotNet" Version="0.11.7-develop" />
<PackageReference Include="Uno.BenchmarkDotNet.Annotations" Version="0.11.7-develop" />
<PackageReference Include="Uno.UI.Skia.Gtk" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />

Просмотреть файл

@ -15,6 +15,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Uno.BenchmarkDotNet" Version="0.11.7-develop" />
<PackageReference Include="Uno.BenchmarkDotNet.Annotations" Version="0.11.7-develop" />
<PackageReference Include="Uno.UI.Skia.Linux.FrameBuffer" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />

Просмотреть файл

@ -20,6 +20,8 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="SkiaSharp.Views" Version="2.80.3" />
<PackageReference Include="Uno.BenchmarkDotNet" Version="0.11.7-develop" />
<PackageReference Include="Uno.BenchmarkDotNet.Annotations" Version="0.11.7-develop" />
<PackageReference Include="Uno.UI.Skia.Tizen" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />

Просмотреть файл

@ -5,6 +5,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Uno.BenchmarkDotNet" Version="0.11.7-develop" />
<PackageReference Include="Uno.BenchmarkDotNet.Annotations" Version="0.11.7-develop" />
<PackageReference Include="Uno.UI.Skia.Wpf" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />

Просмотреть файл

@ -2,6 +2,12 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<ItemGroup>
<PackageReference Include="BenchmarkDotNet">
<Version>0.11.4-develop</Version>
</PackageReference>
<PackageReference Include="BenchmarkDotNet.Annotations">
<Version>0.11.4-develop</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<!--
If, in the same solution, you are referencing a project that uses https://github.com/onovotny/MSBuildSdkExtras,

Просмотреть файл

@ -42,6 +42,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Uno.BenchmarkDotNet" Version="0.11.7-develop" />
<PackageReference Include="Uno.BenchmarkDotNet.Annotations" Version="0.11.7-develop" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
<PackageReference Include="Uno.UI.WebAssembly" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />

Просмотреть файл

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>90B20084-E16C-4528-98C3-77586DE7A1B3</ProjectGuid>
<ProjectGuid>{90B20084-E16C-4528-98C3-77586DE7A1B3}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Benchmarks</RootNamespace>
@ -105,6 +105,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
@ -113,6 +114,12 @@
<BundleResource Include="Resources\Fonts\uno-fluentui-assets.ttf" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Uno.BenchmarkDotNet">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.BenchmarkDotNet.Annotations">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.UI" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
@ -170,11 +177,7 @@
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Folder Include="Media" Visible="false" />
<Folder Include="Media\AppIcons" Visible="false" />
<Folder Include="Media\LaunchImages" Visible="false" />
</ItemGroup>
<ItemGroup />
<Import Project="..\Benchmarks.Shared\Benchmarks.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>

Просмотреть файл

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>4C28189D-9104-4237-8C19-3949C0FBD3FF</ProjectGuid>
<ProjectGuid>{4C28189D-9104-4237-8C19-3949C0FBD3FF}</ProjectGuid>
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Benchmarks.macOS</RootNamespace>
@ -63,12 +63,19 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="Xamarin.Mac" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />
<Reference Include="System.Memory" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Uno.BenchmarkDotNet">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.BenchmarkDotNet.Annotations">
<Version>0.11.7-develop</Version>
</PackageReference>
<PackageReference Include="Uno.UI" Version="4.0.11" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.11" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.11" />
@ -92,11 +99,7 @@
<ImageAsset Include="Assets.xcassets\unologo.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\unologo.imageset\unoplatform.jpg" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="Resources\Fonts\" />
<Folder Include="Assets.xcassets\unologo.imageset\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />

Двоичные данные
src/Benchmarks/PackageCache/BenchmarkDotNet.0.11.4-develop.nupkg Normal file

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Solution Packages" value="PackageCache" />
</packageSources>
</configuration>