Advertisement
Guest User

LLBLGen Pro v4 benchmarks

a guest
Mar 6th, 2013
2,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.08 KB | None | 0 0
  1. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 2886ms
  2. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1319ms
  3. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1331ms
  4. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1224ms
  5. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1208ms
  6. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1270ms
  7. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1207ms
  8. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1232ms
  9. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1197ms
  10. Fetched 31465 LLBLGen Pro v3.5 entities from the DB. Took 1284ms
  11. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 1262ms
  12. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 921ms
  13. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 830ms
  14. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 818ms
  15. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 842ms
  16. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 872ms
  17. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 794ms
  18. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 879ms
  19. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 805ms
  20. Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 862ms
  21. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 1004ms
  22. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 310ms
  23. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 280ms
  24. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 208ms
  25. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 311ms
  26. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 255ms
  27. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 277ms
  28. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 264ms
  29. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 292ms
  30. Fetched 31465 LLBLGen Pro v4 entities with resultset caching from the DB. Took 253ms
  31. Fetched 31465 objects from Dapper in list from the DB. Took 807ms
  32. Fetched 31465 objects from Dapper in list from the DB. Took 714ms
  33. Fetched 31465 objects from Dapper in list from the DB. Took 683ms
  34. Fetched 31465 objects from Dapper in list from the DB. Took 689ms
  35. Fetched 31465 objects from Dapper in list from the DB. Took 649ms
  36. Fetched 31465 objects from Dapper in list from the DB. Took 635ms
  37. Fetched 31465 objects from Dapper in list from the DB. Took 665ms
  38. Fetched 31465 objects from Dapper in list from the DB. Took 632ms
  39. Fetched 31465 objects from Dapper in list from the DB. Took 652ms
  40. Fetched 31465 objects from Dapper in list from the DB. Took 648ms
  41. Fetched 31465 Linq to Sql entities from the DB. Took 738ms
  42. Fetched 31465 Linq to Sql entities from the DB. Took 625ms
  43. Fetched 31465 Linq to Sql entities from the DB. Took 622ms
  44. Fetched 31465 Linq to Sql entities from the DB. Took 604ms
  45. Fetched 31465 Linq to Sql entities from the DB. Took 631ms
  46. Fetched 31465 Linq to Sql entities from the DB. Took 657ms
  47. Fetched 31465 Linq to Sql entities from the DB. Took 600ms
  48. Fetched 31465 Linq to Sql entities from the DB. Took 684ms
  49. Fetched 31465 Linq to Sql entities from the DB. Took 658ms
  50. Fetched 31465 Linq to Sql entities from the DB. Took 609ms
  51. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 4321ms
  52. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1566ms
  53. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1541ms
  54. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1613ms
  55. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1563ms
  56. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1503ms
  57. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1563ms
  58. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1559ms
  59. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1499ms
  60. Fetched 31465 NHibernate v3.3.1.4 entities from the DB. Took 1596ms
  61. Fetched 31465 entity framework v5 entities from the DB. Took 2199ms
  62. Fetched 31465 entity framework v5 entities from the DB. Took 1222ms
  63. Fetched 31465 entity framework v5 entities from the DB. Took 1182ms
  64. Fetched 31465 entity framework v5 entities from the DB. Took 1110ms
  65. Fetched 31465 entity framework v5 entities from the DB. Took 1145ms
  66. Fetched 31465 entity framework v5 entities from the DB. Took 1164ms
  67. Fetched 31465 entity framework v5 entities from the DB. Took 1056ms
  68. Fetched 31465 entity framework v5 entities from the DB. Took 1104ms
  69. Fetched 31465 entity framework v5 entities from the DB. Took 1173ms
  70. Fetched 31465 entity framework v5 entities from the DB. Took 1133ms
  71. Fetched 31465 handcoded objects in list from the DB. Took 675ms
  72. Fetched 31465 handcoded objects in list from the DB. Took 644ms
  73. Fetched 31465 handcoded objects in list from the DB. Took 641ms
  74. Fetched 31465 handcoded objects in list from the DB. Took 615ms
  75. Fetched 31465 handcoded objects in list from the DB. Took 696ms
  76. Fetched 31465 handcoded objects in list from the DB. Took 651ms
  77. Fetched 31465 handcoded objects in list from the DB. Took 633ms
  78. Fetched 31465 handcoded objects in list from the DB. Took 641ms
  79. Fetched 31465 handcoded objects in list from the DB. Took 624ms
  80. Fetched 31465 handcoded objects in list from the DB. Took 657ms
  81. Fetched 31465 rows in datatable from the DB. Took 698ms
  82. Fetched 31465 rows in datatable from the DB. Took 680ms
  83. Fetched 31465 rows in datatable from the DB. Took 664ms
  84. Fetched 31465 rows in datatable from the DB. Took 657ms
  85. Fetched 31465 rows in datatable from the DB. Took 672ms
  86. Fetched 31465 rows in datatable from the DB. Took 671ms
  87. Fetched 31465 rows in datatable from the DB. Took 694ms
  88. Fetched 31465 rows in datatable from the DB. Took 672ms
  89. Fetched 31465 rows in datatable from the DB. Took 664ms
  90. Fetched 31465 rows in datatable from the DB. Took 690ms
  91.  
  92. CODE:
  93. using System;
  94. using System.Collections;
  95. using System.Collections.Generic;
  96. using System.Data;
  97. using System.Data.SqlClient;
  98. using System.Diagnostics;
  99. using System.Linq;
  100. using System.Text;
  101. using System.Threading.Tasks;
  102. using AdventureWorks.Dal.Adapter.DatabaseSpecific;
  103. using AdventureWorks.Dal.Adapter.EntityClasses;
  104. using AdventureWorks.Dal.Adapter.HelperClasses;
  105. using EF.Bencher;
  106. using L2S.Bencher;
  107. using NH.Bencher;
  108. using NHibernate;
  109. using NHibernate.Linq;
  110. using Dapper;
  111. using AdventureWorks.Dal.Adapter.FactoryClasses;
  112. using SD.LLBLGen.Pro.QuerySpec;
  113. using SD.LLBLGen.Pro.QuerySpec.Adapter;
  114. using SD.LLBLGen.Pro.ORMSupportClasses;
  115.  
  116. namespace RawBencher
  117. {
  118.     class Program
  119.     {
  120.         public static string ConnectionString = @"data source=zeusVM\SQLSERVER2005;initial catalog=AdventureWorks;integrated security=SSPI;persist security info=False;packet size=4096";
  121.  
  122.         static void Main(string[] args)
  123.         {
  124.             CacheController.RegisterCache(ConnectionString, new ResultsetCache());
  125.             int loopAmount = 10;
  126.             for(int i = 0; i < loopAmount; i++)
  127.             {
  128.                 FetchSalesOrderHeaderEntitiesv35();
  129.             }
  130.             for(int i = 0; i < loopAmount; i++)
  131.             {
  132.                 FetchSalesOrderHeaderEntities();
  133.             }
  134.             for(int i = 0; i < loopAmount; i++)
  135.             {
  136.                 FetchSalesOrderHeaderEntitiesWithCaching();
  137.             }
  138.             for(int i = 0; i < loopAmount; i++)
  139.             {
  140.                 FetchSalesOrderHeaderDapper();
  141.             }
  142.             for(int i = 0; i < loopAmount; i++)
  143.             {
  144.                 FetchSalesOrderHeaderL2S();
  145.             }
  146.             for(int i = 0; i < loopAmount; i++)
  147.             {
  148.                 FetchSalesOrderHeaderNH();
  149.             }
  150.             for(int i = 0; i < loopAmount; i++)
  151.             {
  152.                 FetchSalesOrderHeaderEF();
  153.             }
  154.             for(int i = 0; i < loopAmount; i++)
  155.             {
  156.                 FetchSalesOrderHeaderHandCoded();
  157.             }
  158.             for(int i = 0; i < loopAmount; i++)
  159.             {
  160.                 FetchSalesOrderHeaderDataTable();
  161.             }
  162.         }
  163.  
  164.  
  165.         public static void FetchSalesOrderHeaderDataTable()
  166.         {
  167.             var sw = new Stopwatch();
  168.             sw.Start();
  169.             var headers = new DataTable();
  170.             using(var con = new SqlConnection(ConnectionString))
  171.             {
  172.                 var cmd = con.CreateCommand();
  173.                 cmd.CommandText = "select * from Sales.SalesOrderHeader";
  174.                 var adapter = new SqlDataAdapter(cmd);
  175.                 adapter.Fill(headers);
  176.             }
  177.             sw.Stop();
  178.             Console.WriteLine("Fetched {0} rows in datatable from the DB. Took {1}ms", headers.Rows.Count, sw.ElapsedMilliseconds);
  179.         }
  180.  
  181.  
  182.         public static void FetchSalesOrderHeaderHandCoded()
  183.         {
  184.             var sw = new Stopwatch();
  185.             sw.Start();
  186.             var headers = new List<SalesOrderHeader>();
  187.             using(var con = new SqlConnection(ConnectionString))
  188.             {
  189.                 var cmd = con.CreateCommand();
  190.                 cmd.CommandText = "select * from Sales.SalesOrderHeader";
  191.                 con.Open();
  192.                 var reader = cmd.ExecuteReader();
  193.                 while(reader.Read())
  194.                 {
  195.                     object fieldValue = null;
  196.                     var soh = new SalesOrderHeader();
  197.                     soh.SalesOrderId = (int)reader.GetValue(0);
  198.                     soh.RevisionNumber = (byte)reader.GetValue(1);
  199.                     soh.OrderDate = (DateTime)reader.GetValue(2);
  200.                     soh.DueDate = (DateTime)reader.GetValue(3);
  201.                     fieldValue = reader.GetValue(4);
  202.                     soh.ShipDate = (DateTime)(fieldValue == DBNull.Value ? null : fieldValue);
  203.                     soh.Status = (byte)reader.GetValue(5);
  204.                     soh.OnlineOrderFlag = (bool)reader.GetValue(6);
  205.                     soh.SalesOrderNumber = (string)reader.GetValue(7);
  206.                     fieldValue = reader.GetValue(8);
  207.                     soh.PurchaseOrderNumber = (string)(fieldValue == DBNull.Value ? null : fieldValue);
  208.                     fieldValue = reader.GetValue(9);
  209.                     soh.AccountNumber = (string)(fieldValue == DBNull.Value ? null : fieldValue);
  210.                     soh.CustomerID = (int)reader.GetValue(10);
  211.                     soh.ContactID = (int)reader.GetValue(11);
  212.                     fieldValue = reader.GetValue(12);
  213.                     soh.SalesPersonID = (int?)(fieldValue == DBNull.Value ? null : fieldValue);
  214.                     fieldValue = reader.GetValue(13);
  215.                     soh.TerritoryID = (int?)(fieldValue == DBNull.Value ? null : fieldValue);
  216.                     soh.BillToAddressID = (int)reader.GetValue(14);
  217.                     soh.ShipToAddressID = (int)reader.GetValue(15);
  218.                     soh.ShipMethodID = (int)reader.GetValue(16);
  219.                     fieldValue = reader.GetValue(17);
  220.                     soh.CreditCardID = (int?)(fieldValue == DBNull.Value ? null : fieldValue);
  221.                     fieldValue = reader.GetValue(18);
  222.                     soh.CreditCardApprovalCode = (string)(fieldValue == DBNull.Value ? null : fieldValue);
  223.                     fieldValue = reader.GetValue(19);
  224.                     soh.CurrencyRateID = (int?)(fieldValue == DBNull.Value?null : fieldValue);
  225.                     soh.SubTotal = (decimal)reader.GetValue(20);
  226.                     soh.TaxAmt = (decimal)reader.GetValue(21);
  227.                     soh.Freight = (decimal)reader.GetValue(22);
  228.                     soh.TotalDue = (decimal)reader.GetValue(23);
  229.                     fieldValue = reader.GetValue(24);
  230.                     soh.Comment = (string)(fieldValue==DBNull.Value ? null : fieldValue);
  231.                     soh.Rowguid = (Guid)reader.GetValue(25);
  232.                     soh.ModifiedDate = (DateTime)reader.GetValue(26);
  233.                     headers.Add(soh);
  234.                 }
  235.                 reader.Close();
  236.                 con.Close();
  237.             }
  238.             sw.Stop();
  239.             Console.WriteLine("Fetched {0} handcoded objects in list from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  240.         }
  241.  
  242.  
  243.         public static void FetchSalesOrderHeaderDapper()
  244.         {
  245.             var sw = new Stopwatch();
  246.             sw.Start();
  247.             var headers = new List<SalesOrderHeader>();
  248.             using(var con = new SqlConnection(ConnectionString))
  249.             {
  250.                 con.Open();
  251.                 headers = con.Query<SalesOrderHeader>("select * from Sales.SalesOrderHeader").ToList();
  252.                 con.Close();
  253.             }
  254.             sw.Stop();
  255.             Console.WriteLine("Fetched {0} objects from Dapper in list from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  256.         }
  257.  
  258.  
  259.         public static void FetchSalesOrderHeaderEntitiesWithCaching()
  260.         {
  261.             var sw = new Stopwatch();
  262.             sw.Start();
  263.             var qf = new QueryFactory();
  264.             var q = qf.SalesOrderHeader.CacheResultset(5);
  265.             var headers = new EntityCollection<SalesOrderHeaderEntity>();
  266.             using(var adapter = new DataAccessAdapter())
  267.             {
  268.                 adapter.FetchQuery(q, headers);
  269.             }
  270.             sw.Stop();
  271.             Console.WriteLine("Fetched {0} LLBLGen Pro v4 entities with resultset caching from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  272.         }
  273.        
  274.  
  275.         public static void FetchSalesOrderHeaderEntities()
  276.         {
  277.             var sw = new Stopwatch();
  278.             sw.Start();
  279.             var headers = new EntityCollection<SalesOrderHeaderEntity>();
  280.             using(var adapter = new DataAccessAdapter())
  281.             {
  282.                 adapter.FetchEntityCollection(headers, null);
  283.             }
  284.             sw.Stop();
  285.             Console.WriteLine("Fetched {0} LLBLGen Pro v4 entities from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  286.         }
  287.  
  288.  
  289.         public static void FetchSalesOrderHeaderEntitiesv35()
  290.         {
  291.             var sw = new Stopwatch();
  292.             sw.Start();
  293.             var headers = new LLBL35.AW.HelperClasses.EntityCollection<LLBL35.AW.EntityClasses.SalesOrderHeaderEntity>();
  294.             using(var adapter = new LLBL35.AW.DatabaseSpecific.DataAccessAdapter())
  295.             {
  296.                 adapter.FetchEntityCollection(headers, null);
  297.             }
  298.             sw.Stop();
  299.             Console.WriteLine("Fetched {0} LLBLGen Pro v3.5 entities from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  300.         }
  301.  
  302.  
  303.         public static void FetchSalesOrderHeaderEF()
  304.         {
  305.             var sw = new Stopwatch();
  306.             sw.Start();
  307.             List<EF.Bencher.EntityClasses.SalesOrderHeader> headers = null;
  308.             using(var ctx = new EFBencherDataContext())
  309.             {
  310.                 headers = ctx.SalesOrderHeaders.ToList();
  311.             }
  312.             sw.Stop();
  313.             Console.WriteLine("Fetched {0} entity framework v5 entities from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  314.         }
  315.  
  316.         public static void FetchSalesOrderHeaderL2S()
  317.         {
  318.             var sw = new Stopwatch();
  319.             sw.Start();
  320.             List<L2S.Bencher.EntityClasses.SalesOrderHeader> headers = null;
  321.             var ctx = new L2SBencherDataContext();
  322.             headers = ctx.SalesOrderHeaders.ToList();
  323.             sw.Stop();
  324.             Console.WriteLine("Fetched {0} Linq to Sql entities from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  325.         }
  326.  
  327.         public static void FetchSalesOrderHeaderNH()
  328.         {
  329.             var sw = new Stopwatch();
  330.             sw.Start();
  331.             List<NH.Bencher.EntityClasses.SalesOrderHeader> headers = null;
  332.             using(var session = SessionManager.OpenSession())
  333.             {
  334.                 headers = session.Query<NH.Bencher.EntityClasses.SalesOrderHeader>().ToList();
  335.             }
  336.             sw.Stop();
  337.             Console.WriteLine("Fetched {0} NHibernate v3.3.1.4 entities from the DB. Took {1}ms", headers.Count, sw.ElapsedMilliseconds);
  338.         }
  339.     }
  340. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement