BenchmarkRunner.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using BenchmarkDotNet.Attributes;
  2. using BenchmarkDotNet.Configs;
  3. namespace App.OrmRunner
  4. {
  5. [Config(typeof(Config))]
  6. //[Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.FastestToSlowest)]
  7. [InProcess]
  8. public class BenchmarkRunner
  9. {
  10. private class Config : ManualConfig
  11. {
  12. // https://benchmarkdotnet.org/articles/configs/configs.html
  13. public Config()
  14. {
  15. WithOptions(ConfigOptions.DisableOptimizationsValidator);
  16. }
  17. }
  18. //[Params(100)]
  19. public int N = 100;
  20. //[Params(true, false)]
  21. public bool executeQuery = true;
  22. [Params(false, true)]
  23. public bool queryJoin = false;
  24. [Params(0, 10)]
  25. public int? skip = 10;
  26. [Params(10, 1000)]
  27. public int take = 100;
  28. [Params(typeof(Runner_Vitorm), typeof(Runner_EntityFramework) )]
  29. public Type runner;
  30. IRunner queryTest;
  31. [GlobalSetup]
  32. public void Setup()
  33. {
  34. queryTest = Activator.CreateInstance(runner) as IRunner;
  35. }
  36. [Benchmark]
  37. public void Run()
  38. {
  39. var config = new RunConfig { repeatCount = N, executeQuery = executeQuery, queryJoin = queryJoin, skip = skip, take = take };
  40. queryTest.Run(config);
  41. }
  42. }
  43. }