Skip to content

Commit 9d99651

Browse files
authored
Merge pull request #841 from unoplatform/dev/erli/828-benchmark
chore: Update Benchmark to Uno.Sdk 5.4
2 parents 55afbf8 + 70c3102 commit 9d99651

File tree

11 files changed

+161
-199
lines changed

11 files changed

+161
-199
lines changed

UI/Benchmark/AppBenchmark/AppBenchmark/App.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<Application x:Class="AppBenchmark.App"
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
1+
<Application x:Class="AppBenchmark.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
44

55
<Application.Resources>
66
<ResourceDictionary>

UI/Benchmark/AppBenchmark/AppBenchmark/App.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using Microsoft.Extensions.Logging;
31
using Uno.Resizetizer;
42

53
namespace AppBenchmark;

UI/Benchmark/AppBenchmark/AppBenchmark/AppBenchmark.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
<Description>AppBenchmark powered by Uno Platform.</Description>
1919
<!--
2020
If you encounter this error message:
21-
2221
error NETSDK1148: A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll.
2322
Please update to a newer .NET SDK in order to reference this assembly.
24-
2523
This means that the two packages below must be aligned with the "build" version number of
2624
the "Microsoft.Windows.SDK.BuildTools" package above, and the "revision" version number
2725
must be the highest found in https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref.
2826
-->
29-
<!-- <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> -->
27+
28+
<!-- Uno Platform 5.4 has been updated to use WinAppSDK 1.6, which necessitates a temporary version adjustment until newer versions of .NET 8 SDKs are released. -->
29+
<!-- Comment this WindowsSdkPackageVersion line again once .NET SDK version 8.0.403 or later is available. -->
30+
<!-- For more details, refer to: https://aka.platform.uno/migrate-from-previous#uno-platform-54 -->
31+
<WindowsSdkPackageVersion>10.0.19041.38</WindowsSdkPackageVersion>
3032

3133
<!--
3234
UnoFeatures let's you quickly add and manage implicit package references based on the features you want to use.

UI/Benchmark/AppBenchmark/AppBenchmark/BenchmarkDotNetControl.xaml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
<UserControl
2-
x:Class="AppBenchmark.BenchmarkDotNetControl"
3-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:local="using:Benchmarks.Shared.Controls"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
mc:Ignorable="d"
9-
d:DesignHeight="300"
10-
d:DesignWidth="400">
1+
<UserControl x:Class="AppBenchmark.BenchmarkDotNetControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="using:Benchmarks.Shared.Controls"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300"
9+
d:DesignWidth="400">
1110

1211
<Grid>
1312
<Grid>
@@ -17,22 +16,22 @@
1716
</Grid.RowDefinitions>
1817
<StackPanel Grid.Row="0">
1918
<TextBox PlaceholderText="Class name contains..."
20-
Width="400"
21-
Text="{x:Bind ClassFilter, Mode=TwoWay}"
22-
HorizontalAlignment="Left" />
19+
Width="400"
20+
Text="{x:Bind ClassFilter, Mode=TwoWay}"
21+
HorizontalAlignment="Left" />
2322
<Button x:Name="runButton"
24-
Content="Run Benchmarks"
25-
Click="OnRunTests" />
23+
Content="Run Benchmarks"
24+
Click="OnRunTests" />
2625
<TextBlock x:Name="runStatus"
27-
Text="Not initialized" />
26+
Text="Not initialized" />
2827
</StackPanel>
2928
<ScrollViewer Grid.Row="1"
30-
Background="Black"
31-
Padding="12">
29+
Background="Black"
30+
Padding="12">
3231
<TextBlock x:Name="runLogs"
33-
FontFamily="Courier New"
34-
FontSize="12"
35-
IsTextSelectionEnabled="True" />
32+
FontFamily="Courier New"
33+
FontSize="12"
34+
IsTextSelectionEnabled="True" />
3635
</ScrollViewer>
3736
</Grid>
3837
</Grid>
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1-
using BenchmarkDotNet.Attributes;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Text;
1+
using BenchmarkDotNet.Attributes;
52

6-
namespace SamplesApp.Benchmarks.Suite.FinalizerBench
3+
namespace SamplesApp.Benchmarks.Suite.FinalizerBench;
4+
5+
public class FinalizerBenchmark
76
{
8-
public class FinalizerBenchmark
7+
[Benchmark(Baseline = true)]
8+
public void NewHandles()
99
{
10-
[Benchmark(Baseline = true)]
11-
public void NewHandles()
10+
for (int i = 0; i < 100; i++)
1211
{
13-
for (int i = 0; i < 100; i++)
14-
{
15-
new WithFinalizer();
16-
}
12+
new WithFinalizer();
1713
}
14+
}
1815

1916

20-
[Benchmark()]
21-
public void ReuseHandle()
17+
[Benchmark()]
18+
public void ReuseHandle()
19+
{
20+
for (int i = 0; i < 100; i++)
2221
{
23-
for (int i = 0; i < 100; i++)
24-
{
25-
new WithoutFinalizer();
26-
}
27-
22+
new WithoutFinalizer();
2823
}
2924

30-
private class WithFinalizer
25+
}
26+
27+
private class WithFinalizer
28+
{
29+
~WithFinalizer()
3130
{
32-
~WithFinalizer()
33-
{
3431

35-
}
3632
}
33+
}
3734

38-
private class WithoutFinalizer
39-
{
35+
private class WithoutFinalizer
36+
{
4037

41-
}
4238
}
4339
}
Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
1-
using BenchmarkDotNet.Attributes;
2-
using System;
3-
using System.Collections.Generic;
1+
using BenchmarkDotNet.Attributes;
42
using System.Runtime.InteropServices;
5-
using System.Text;
63

7-
namespace SamplesApp.Benchmarks.Suite.GCHandleBench
4+
namespace SamplesApp.Benchmarks.Suite.GCHandleBench;
5+
6+
public class GCHandleBenchmark
87
{
9-
public class GCHandleBenchmark
8+
[Benchmark(Baseline = true)]
9+
public void NewHandles()
1010
{
11-
[Benchmark(Baseline = true)]
12-
public void NewHandles()
13-
{
14-
int counter = 0;
11+
int counter = 0;
1512

16-
for (int i = 0; i < 100; i++)
13+
for (int i = 0; i < 100; i++)
14+
{
15+
var o = new Object();
16+
var h = GCHandle.Alloc(o, GCHandleType.Normal);
17+
var o2 = h.Target;
18+
if (o2 != null)
1719
{
18-
var o = new Object();
19-
var h = GCHandle.Alloc(o, GCHandleType.Normal);
20-
var o2 = h.Target;
21-
if (o2 != null)
22-
{
23-
counter++;
24-
}
25-
h.Free();
20+
counter++;
2621
}
22+
h.Free();
2723
}
24+
}
2825

2926

30-
[Benchmark()]
31-
public void ReuseHandle()
32-
{
33-
int counter = 0;
27+
[Benchmark()]
28+
public void ReuseHandle()
29+
{
30+
int counter = 0;
3431

35-
var o = new Object();
36-
var h = GCHandle.Alloc(o, GCHandleType.Normal);
32+
var o = new Object();
33+
var h = GCHandle.Alloc(o, GCHandleType.Normal);
3734

38-
for (int i = 0; i < 100; i++)
35+
for (int i = 0; i < 100; i++)
36+
{
37+
var o2 = h.Target;
38+
if (o2 != null)
3939
{
40-
var o2 = h.Target;
41-
if (o2 != null)
42-
{
43-
counter++;
44-
}
40+
counter++;
4541
}
46-
47-
h.Free();
4842
}
43+
44+
h.Free();
4945
}
5046
}
Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,41 @@
1-
using BenchmarkDotNet.Attributes;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
1+
using BenchmarkDotNet.Attributes;
62

7-
namespace SamplesApp.Benchmarks.Suite.SpanBench
3+
namespace SamplesApp.Benchmarks.Suite.SpanBench;
4+
5+
public class SpanTesting
86
{
9-
public class SpanTesting
10-
{
11-
[Params(10, 20)]
12-
public int Items { get; set; }
7+
[Params(10, 20)]
8+
public int Items { get; set; }
139

14-
[Benchmark(Baseline = true)]
15-
public void EnumerableSum()
16-
{
17-
var r = Enumerable.Range(0, Items).ToArray();
10+
[Benchmark(Baseline = true)]
11+
public void EnumerableSum()
12+
{
13+
var r = Enumerable.Range(0, Items).ToArray();
1814

19-
var s = r.Sum();
20-
}
15+
var s = r.Sum();
16+
}
2117

2218

23-
[Benchmark()]
24-
public void SpanSum()
25-
{
26-
var r = Enumerable.Range(0, Items).ToArray();
19+
[Benchmark()]
20+
public void SpanSum()
21+
{
22+
var r = Enumerable.Range(0, Items).ToArray();
2723

28-
var s = ((Span<int>)r).Sum();
29-
}
24+
var s = ((Span<int>)r).Sum();
3025
}
26+
}
3127

32-
public static class Extensions
28+
public static class Extensions
29+
{
30+
public static double Sum(this Span<int> span)
3331
{
34-
public static double Sum(this Span<int> span)
35-
{
36-
double result = 0;
32+
double result = 0;
3733

38-
foreach (var value in span)
39-
{
40-
result += value;
41-
}
42-
43-
return result;
34+
foreach (var value in span)
35+
{
36+
result += value;
4437
}
38+
39+
return result;
4540
}
4641
}

0 commit comments

Comments
 (0)