Program.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using App.QueryTest;
  2. using BenchmarkDotNet.Attributes;
  3. using BenchmarkDotNet.Order;
  4. using BenchmarkDotNet.Running;
  5. namespace App
  6. {
  7. public class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. QueryTest_Vitorm.InitDb();
  12. //new QueryTest_Vitorm().Query(take: 100);
  13. //new QueryTest_Vitorm().QueryJoin(take: 100);
  14. //new QueryTest_EntityFramework().Query(take: 100);
  15. //new QueryTest_EntityFramework().QueryJoin(take: 100);
  16. var summary = BenchmarkRunner.Run<VitormBenchmark>();
  17. //BenchmarkRunner.Run<OtherTest.VitormBenchmark_ReduceMember>();
  18. }
  19. [Orderer(SummaryOrderPolicy.FastestToSlowest)]
  20. [InProcess]
  21. public class VitormBenchmark
  22. {
  23. [Params(100)]
  24. public int N;
  25. [Params(10, 100, 500, 1000)]
  26. public int rowCount;
  27. [Params(typeof(QueryTest_Vitorm), typeof(QueryTest_EntityFramework))]
  28. public Type testType;
  29. [Params(true, false)]
  30. public bool queryJoin;
  31. IBenchmarkQuery queryTest;
  32. [GlobalSetup]
  33. public void Setup()
  34. {
  35. queryTest = Activator.CreateInstance(testType) as IBenchmarkQuery;
  36. }
  37. [Benchmark]
  38. public void Run()
  39. {
  40. var config = new QueryConfig { repeatCount = N, queryJoin = queryJoin, take = rowCount };
  41. queryTest.Query(config);
  42. }
  43. }
  44. }
  45. }