使用实体框架,32位和64位的性能差异 [英] Performance difference using entity framework in 32 bit and 64 bit

查看:391
本文介绍了使用实体框架,32位和64位的性能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用中使用实体框架中的.NET Framework 4.0。

I'm using Entity Framework in .NET Framework 4.0 in an application.

将操作系统升级到64位版本后,我发现高CPU使用率在应用程序。

After upgrading the operating system to a 64 bit version I noticed higher CPU usage in the application.

编译应用程序专门针对x86(而不是任何CPU如前)申请回来大约相同的CPU使用的操作系统升级之前。

Compiling the application specifically for x86 (instead of any CPU as before) the application got back to about the same CPU usage as before the operating system upgrade.

我用下面的code做了一些更详细的测量

I did some more detailed measuring using the below code

某些热身code为前运行,以便创建上下文的第一时间和运行查询首次的开销不测量。这些案件是不是很有意思我的应用程序,因为它是一个长期运行的应用程序

var s = Stopwatch.StartNew();
var name = "name";
for (var i = 0; i < 100000; ++i) {
    using (var context = new MyDatabaseEntities()) {
        var entity = context.MyEntities.FirstOrDefault(e => e.Name == name);
    }
}
s.Stop();

在code以上编译无论是x86或x64(任何CPU给出了相同的结果,64位),并运行Windows 7的64位计算机上。 (该数据库是在不同的机器上运行)

The code above compiled either for x86 or x64 (Any CPU gives the same results as x64) and run on a Windows 7 64 bit machine. (The database is running on a different machine)

给出了12%x86s赞成的性能差异。即如果在x86版本的运行每秒100个查询,然后将64位版本的运行每秒88查询。

Gives a performance difference of 12% in x86s favor. I.e. if the x86 version runs 100 queries per second, then the x64 version runs 88 queries per second.

这是预期/正常的表现32位和64位的.NET的区别是什么?

Is this an expected/normal performance difference between 32bit and 64bit on .NET?

有什么我可以做的就是在64位版本相同的性能在32位版本?

Is there something I can do to get the same performance in the 64 bit version as in the 32 bit version?

在上面的例子中myEntity所是一个具有一个ID和一个名称很简单的实体

通常情况下,应用程序运行作为一个窗口服务,但在测量时,它运行作为一个正常的Windows应用程序(WPF)

推荐答案

在我来说,我使用的,因为该内存使用asp.net和x86超过2GB低。在64位将增加一倍memorou用法,但你可以分配超过2GB。这是一个类似的问题: 64 VS 86性能考虑净

In my case i use asp.net and x86 because of the memory usage is lower than 2gb. The x64 will double memorou usage, but you can allocate over 2gb. Here is a similar question: x64 vs x86 Performance Considerations .Net

这篇关于使用实体框架,32位和64位的性能差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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