通过引用dll提高CPU利用率

通过引用dll提高CPU利用率

本文介绍了通过引用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

推荐答案

即用数据包信息更新此结构的代码和/或每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 avery 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.


这篇关于通过引用dll提高CPU利用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:03