Program.cs 1.1 KB

12345678910111213141516171819202122232425262728
  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.Linq;
  4. using System.Reflection;
  5. using BenchmarkDotNet.Attributes;
  6. using BenchmarkDotNet.Running;
  7. namespace Avalonia.Benchmarks
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // Use reflection for a more maintainable way of creating the benchmark switcher,
  14. // Benchmarks are listed in namespace order first (e.g. BenchmarkDotNet.Samples.CPU,
  15. // BenchmarkDotNet.Samples.IL, etc) then by name, so the output is easy to understand
  16. var benchmarks = Assembly.GetExecutingAssembly().GetTypes()
  17. .Where(t => t.GetMethods(BindingFlags.Instance | BindingFlags.Public)
  18. .Any(m => m.GetCustomAttributes(typeof(BenchmarkAttribute), false).Any()))
  19. .OrderBy(t => t.Namespace)
  20. .ThenBy(t => t.Name)
  21. .ToArray();
  22. var benchmarkSwitcher = new BenchmarkSwitcher(benchmarks);
  23. benchmarkSwitcher.Run(args);
  24. }
  25. }
  26. }