From 219a0da799e954516b9c50eb2ad41c8feae533ba Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 17 Jun 2018 18:56:47 +0200 Subject: [PATCH] Added benchmarks for PathMarkupParser. --- .../Avalonia.Benchmarks.csproj | 5 ++- .../Visuals/Media/PathMarkupParserTests.cs | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/Avalonia.Benchmarks/Visuals/Media/PathMarkupParserTests.cs diff --git a/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj b/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj index 9e92baf0ff..a460ab5bf3 100644 --- a/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj +++ b/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj @@ -1,6 +1,7 @@  - netcoreapp2.0 + netcoreapp2.0 + Exe @@ -15,7 +16,7 @@ - + diff --git a/tests/Avalonia.Benchmarks/Visuals/Media/PathMarkupParserTests.cs b/tests/Avalonia.Benchmarks/Visuals/Media/PathMarkupParserTests.cs new file mode 100644 index 0000000000..6d0027fe23 --- /dev/null +++ b/tests/Avalonia.Benchmarks/Visuals/Media/PathMarkupParserTests.cs @@ -0,0 +1,39 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using Avalonia.Media; +using Avalonia.UnitTests; +using BenchmarkDotNet.Attributes; + +namespace Avalonia.Benchmarks.Visuals.Media +{ + [MemoryDiagnoser] + public class PathMarkupParserTests : IDisposable + { + private IDisposable _app; + + public PathMarkupParserTests() + { + _app = UnitTestApplication.Start(TestServices.StyledWindow); + } + + public void Dispose() + { + _app.Dispose(); + } + + [Benchmark] + public void Parse_Large_Path() + { + var path = "F1 M 16.6309 18.6563C 17.1309 8.15625 29.8809 14.1563 29.8809 14.1563C 30.8809 11.1563 34.1308 11.4063" + + " 34.1308 11.4063C 33.5 12 34.6309 13.1563 34.6309 13.1563C 32.1309 13.1562 31.1309 14.9062 31.1309 14.9" + + "062C 41.1309 23.9062 32.6309 27.9063 32.6309 27.9062C 24.6309 24.9063 21.1309 22.1562 16.6309 18.6563 Z" + + " M 16.6309 19.9063C 21.6309 24.1563 25.1309 26.1562 31.6309 28.6562C 31.6309 28.6562 26.3809 39.1562 18" + + ".3809 36.1563C 18.3809 36.1563 18 38 16.3809 36.9063C 15 36 16.3809 34.9063 16.3809 34.9063C 16.3809 34" + + ".9063 10.1309 30.9062 16.6309 19.9063 Z "; + var parser = new PathMarkupParser(); + var result = parser.Parse(path); + } + } +}