通过引用dll提高CPU利用率

问题描述:

Hi,

我正在开发一个旧版Winforms应用程序,该应用程序在其上包含许多用户控件
嵌入在WinCE 6.0 OS中的.NET 2.0 Compact Framework.作为代码的一部分
重构中,我添加了一个名为Utilities的dll,并根据需要引用了该dll,
主应用程序和用户控件.在Utilities.dll中,我添加了一个静态类
包含一个可容纳2个整数(一个长整数和一个布尔值)的结构.
结构用于保存实时数据包信息.实时
数据被广泛用于在图形上的
处绘制各种图形 每隔50毫秒的时间间隔.

I am working on a legacy Winforms application that includes many user controls on
.NET 2.0 Compact Framework embedded in WinCE 6.0 OS. As part of code
refactoring, I added a dll named Utilities and reference the dll as needed by
the main app and user controls. Within the Utilities.dll I added a static class
containing a structure that holds 2 integers, one long and one boolean. The
structure is used to hold the realtime data packet information. The realtime
data is used extensively for drawing various graphs on the Graphics at an
interval of every 50ms.

通过添加实用程序dll,我发现CPU的使用量有所增加
利用率约8%.谁能告诉我为什么CPU数量增加了吗?
仅在.dll中添加结构并引用它的用法.在
内 构建项目属性我已经检查了优化代码"选项.有没有
其他需要完成的相关项目设置?

With the addition of the Utilities dll I am seeing an increase in the CPU
Utilization ~8%. Can anyone please let know why there is an increase in CPU
Usage with just adding a structure in a .dll and referencing it. Within the
Build project properties I have checked the Optimize code option. Are there any
other relevant project settings that need to be done?

谢谢,

Chethana

CPU利用率的提高与仅引用DLL无关,而与如何引用DLL有关.正在使用其中的静态类!

The increase in CPU utilitisation is not going to be anything to do with just referencing the DLL, but with how the static class within it is being used!

即用数据包信息更新此结构的代码和/或每50毫秒更新图形的代码(听起来像是 非常很短的时间间隔(用于更新GUI)将是造成这种情况的原因.

i.e. the code that updates this structure with packet information and/or the code that updates the graphs every 50ms (which sounds like a very short time interval for updating  a GUI) is going to be the cause of this.

您可能需要更多地跟踪/分析该代码,并且如果可以缩小范围,则可能会发布一些代码示例.

You may need to trace/profile that code through a bit more and possibly post some code samples if you can narrow it down.