Program.cs 1005 B

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