Linq To Sql vs实体框架性能 [英] Linq To Sql vs Entity Framework Performance

查看:104
本文介绍了Linq To Sql vs实体框架性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找比较L2S和EF的最新性能基准,并且找不到使用发布的EF的任何测试过的调用存储过程。所以,我运行了一些我自己的测试,并发现一些有趣的结果。

I have been searching for recent performance benchmarks that compare L2S and EF and couldnt find any that tested calling stored procedures using the released version of EF. So, I ran some of my own tests and found some interesting results.

这些结果是否正确?我应该用不同的方式进行测试吗?

Do these results look right? Should I be testing it in a different way?

上下文的一个实例,sproc的一个调用:
(dead link)

One instance of the context, one call of the sproc: (dead link)

上下文的一个实例,同一个sproc的多个调用:
(dead link)

One instance of the context, multiple calls of the same sproc: (dead link)

上下文,同一个sproc的多个调用:
(dead link)

Multiple instances of the context, multiple calls of the same sproc: (dead link)

推荐答案

我想你应该在有些不同的方式,以区分启动成本与执行成本。实体框架尤其具有实质性的需要编译数据库视图而产生的启动成本(虽然可以提前做到这一点)。同样,LINQ有一个概念,一个编译查询,如果多次执行查询,这将是适当的。

I think you should test it in a somewhat different way, in order to distinguish startup costs vs. execution costs. The Entity Framework, in particular, has substantial startup costs resulting from the need to compile database views (although you can do this in advance). Likewise, LINQ has a notion of a compiled query, which would be appropriate if executing a query multiple times.

对于许多应用程序,查询执行成本将比启动成本更为重要。对于某些人来说,相反的可能是真的。由于这些性能特点不同,我认为区分它们很重要。特别地,将启动成本平均为重复执行的查询的平均成本是误导的。

For many applications, query execution costs will be more important than startup costs. For some, the opposite may be true. Since the performance characteristics of these are different, I think it's important to distinguish them. In particular, averaging startup costs into the average cost of a query executed repeatedly is misleading.

这篇关于Linq To Sql vs实体框架性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆