Benchmarking: ADO.NET Entity Framework vs Subsonic
ADO.NET Entity Framework vs Subsonic: performance benchmarking and other comparisons
Entity Framework is a relatively new feature of .NET, for automatically generating and maintaining the data access layer and business objects in an application. The developer can simply point the framework at the database using a simple wizard in the Visual Studio IDE, click "Finish", and the work is done. Data is then available in every imaginable way with simple, intuitive properties and methods in unmanaged code. Strongly-typed objects are also available for every data structure.
Subsonic is an open source command line utility which does a similar job. It's very well established and has been widely adopted.
There have been various attempts at solutions for this approach to rapid development, broadly known as object-relational mapping. But how good is the generated code, and how good are the libraries? There are numerous measures that would be useful in comparing any two ORM products, both qualitative and quantitative. I aim to test all of them. My initial test was to compare Entity Framework and Subsonic for the simple task of loading all records in a table. I created a basic table with 1000 rows and loaded all of the data into strongly-typed lists 100 times in an ASP.NET MVC web page. I loaded the web page 5 times, allowing 5 seconds between each refresh, and recorded the time taken for the loop to execute.
Entity Framework is much faster than Subsonic.
This speed difference between Entity Framework and Subsonic is greatest in the first burst of database reads. I observed in other tests that the gap between the two increases exponentially with the number of records. Perfect integration with Visual Studio also makes EF much quicker and easier to set up and maintain. The code the developer needs to write to utilise EF was simpler and clearer, although in both cases it is minimal (1 line).
Raw data from the first test below. Downloadable "try it yourself" project and source code from my tests coming soon... More data coming soon... More tests coming soon...
|Entity Framework||Subsonic (milliseconds)|
- SQL Server 2005 Express Edition with Advanced Services
- .Net Framework 3.5 (Linq 3.5), Enterprise Library 4.1
- Subsonic 2.1 (similar results produced with 3.0)
01 June 2009