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

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

问题描述

我一直在寻找比较 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 的一个调用:(死链接)

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

上下文的一个实例,同一个 sproc 的多次调用:(死链接)

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

上下文的多个实例,同一sproc的多次调用:(死链接)

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 与实体框架性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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