PathMarkupParserTests.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using Avalonia.Media;
  5. using Avalonia.UnitTests;
  6. using BenchmarkDotNet.Attributes;
  7. namespace Avalonia.Benchmarks.Visuals.Media
  8. {
  9. [MemoryDiagnoser]
  10. public class PathMarkupParserTests : IDisposable
  11. {
  12. private IDisposable _app;
  13. public PathMarkupParserTests()
  14. {
  15. _app = UnitTestApplication.Start(TestServices.StyledWindow);
  16. }
  17. public void Dispose()
  18. {
  19. _app.Dispose();
  20. }
  21. [Benchmark]
  22. public void Parse_Large_Path()
  23. {
  24. const string PathData = "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" +
  25. " 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" +
  26. "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" +
  27. " 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" +
  28. ".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" +
  29. ".9063 10.1309 30.9062 16.6309 19.9063 Z ";
  30. var streamGeometry = new StreamGeometry();
  31. using (var context = streamGeometry.Open())
  32. using (var parser = new PathMarkupParser(context))
  33. {
  34. parser.Parse(PathData);
  35. }
  36. }
  37. }
  38. }