.Net和COM组件之间传递数据的性能组件、性能、数据、Net

2023-09-04 02:54:47 作者:寂寞式丶

我在迁移旧版VB6应用程序到.NET的过程中,但因为它是一个高调的关键业务应用,它是由一块一块做的。

I am in the process of migrating a legacy VB6 app to .Net, however since it is a high-profile business critical application, it is being done piece by piece.

在提高性能的利益,有一种方法在应用程序的生命在此期间,被打了很多,几千次,而我想重写它的.Net(C#),看看是否运行时可以得到改善。

In the interest of improving performance, there is one method which gets hit a lot,thousands of times during the application life, and I was wanting to rewrite it in .Net (C#) to see if the runtime can be improved.

在讨论的方法操纵ADODB记录集。是否有任何性能问题,我应该知道或考虑到,因为这些记录集将通过COM互操作?

The method in question manipulates ADODB Recordsets. Is there any performance issues I should be aware of or take into consideration since these recordsets will be passed to and from VB6 via COM interop?

推荐答案

我没有做过具体的有关数据,但根据我的经验与互操作什么,.NET是很好的优化,通常为每互操作调用赢得API或COM只引入开销可忽略不计的纳米秒。 ADO记录集只会被同等对待的非托管堆和引擎盖下创建的任何其他COM对象是他们处理IntPtr的地址。

I haven't done anything specific on this but from my experience with Interop, .NET is very well optimized and usually per interop call to Win API or COM only introduces nano seconds of overhead that is negligible. ADO Recordset will just be treated the same as any other COM objects created on unmanaged heap and under the hood is the IntPtr address that they deal with.

本地.NET框架库和它的垃圾收集器是远远优于什么avaialble在VB。我相信重写你的一些旧的VB code。在.NET中可能会给你一些性能提升更多或至少足以忽略互操作的开销。如果你装备自己与分析器工具,时间可持续监视性能为您实施逐件迁移最佳。

Native .NET framework library and its garbage collector is far superior than whats avaialble in VB. I believe rewriting some of your old VB code in .NET may give you some performance gain more or at least enough to ignore the interop overhead. Best if you equip yourself with a profiler tool and continuosly monitor performance as you migrate the implementation piece by piece.