.net C 在Win32/COM方法上调用PInvoke时,通常有一个明显的性能下降吗?
我打算利用各种Win32方法,并希望更好地了解这样做的负面影响。
谢谢,
布莱恩。
|
我想知道有没有人有一个体面的解释或概述在使用DLLImport / PInvoke在Win32方法从负责的网络代码? 我打算利用各种Win32方法,并希望更好地了解这样做的负面影响。 谢谢, 布莱恩。 根据 MSDN C Calling Native Functions from Managed CodePInvoke has an overhead of between 10 and 30 x86 instructions per call. In addition to this fixed cost,marshaling creates additional overhead. There is no marshaling cost between blittable types that have the same representation in managed and unmanaged code. For example,there is no cost to translate between int and Int32. 根据我的经验,当P /调用本机功能时,绝对会有一个开销,但是通常性能下降并不值得担心。封送费用是要记住的。如果您正在传递大型结构,字符串等,那么性能成本将很快显现。 对于非常频繁调用的P /调用函数,您可能需要考虑将[SuppressUnmanagedCodeSecurity]添加到P / Invoke函数定义(参见MSDN C SuppressUnmanagedCodeSecurityAttribute)。这将使运行时停止堆栈步行,以确保调用者具有非管理代码权限。当然,请确保您在添加此属性之前了解安全性后果。 (编辑:东莞站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-phone-7 – Caliburn Micro中的墓碑
- 命令行 – 批处理脚本 – 更改桌面上文件夹的图标(Windows
- Windows – LogonUser – 来自系统服务的CreateProcessAsUs
- 02、Windows Server 2003域账户管理(02)
- .net – Windows Azure上的AspPDF和AspJPEG
- edge浏览器中对pdf编辑的制作是怎样的
- 飞溅屏幕 – 通用窗口10个应用程序的Splash屏幕
- 教你win10下安装win7双系统后启动没有引导菜单如何处理
- 微软 Windows 11 23H2 桌面应用文件夹功能泄露
- windows-phone-8.1 – 升级到最新Windows Phone 8.1后无法发
