While developing one of my applications using the ActiveX Xtreme Suite, I noticed that CPU utilization was abnormally high. I initially attributed this to the type of processing I was doing in the CommandBars 'Update' event to ensure my toolbars were properly enabled/disabled. Since this event was constantly firing when a toolbar was visible, I assumed I needed to minimize the amount of processing performed in this routine. After spending tens of hours trying to minimize and tweak my code to decrease CPU utilization, I ran out of ideas and never got the CPU at an acceptable level.
I since started working on another application that did not involve a lot of processing in the 'Update' event. I was suprised to later find out that the application still had high CPU utilization.
I finally decided to build a test applicaiton that was similar in design to my other applications except that it did very little (if any) processing. All it does is load and display forms. There is no updating of any CommandBarControls.
The application is a typical MDI application. The MDI Form has a CommandBars control that supplies the main menu (no toolbars). Each child window contains two docked panes (one with a PropertyGrid and the other with a TextBox). In one version of the application, the two docked panes also contain a CommandBars object (although nothing is loaded or displayed for those controls).
Now I have two similar applications:
- ResourceTest.exe - application with CommandBars on each docked pane in the Child Window
- ResourceTest2.exe - application with no CommandBars on the docked panes of the Child Window
I then performed some basic tests on two machines. On each machine, I invidivually loaded each of the two applications. I would then open new child windows and watch the percentage of CPU utilization in the Task Manager as I added new windows. I would also check the impact that DocumentTabs had on CPU utilization. Since ResourceTest2.exe did not have CommandBars on each child form, I expected it to consume less of the CPU. The results are below:
Pentium 4 1.7GHz 256MB RAM WinNT 4.0 ResourceTest.exe 10 Childs = 20% (20% no Doc Tabs) 15 Childs = 50% (40% no Doc Tabs) 18 Childs = 99% (80% no Doc Tabs) ResourceTest2.exe 10 Childs = 0% ( 0% no Doc Tabs) 20 Childs = 0% ( 0% no Doc Tabs) 30 Childs = 30% (20% no Doc Tabs) 35 Childs = 99% (25% no Doc Tabs) 38 Childs = 99% (95% no Doc Tabs)
Pentium II 400MHz 256MB RAM Win2000 ResourceTest.exe 5 Childs = 10% (10% no Doc Tabs) 10 Childs = 80% (70% no Doc Tabs) 15 Childs = 99% (95% no Doc Tabs) ResourceText2.exe 10 Childs = 10% ( 5% no Doc Tabs) 20 Childs = 70% (50% no Doc Tabs) 25 Childs = 99% (99% no Doc Tabs)
These results show a lot of CPU utilization considering the application itself is doing nothing. I've attached the project source code and exectable files for the two test applications. You'll need CommandBars, DockingPane, and PropertyGrid registered on the machine to run the examples.
Dont' get me wrong. I absolutely love these controls!! They provide a very professional look-and-feel to the application. My concern is that my clients will not want to use my application if it is constantly consuming a minimum of 10% of the CPU.
Has anyone else seen this problem? Is there something I'm doing wrong in my implementation of the controls?
Codejock, can anything be done to reduce CPU utilization?
Sample Projects Attached: http://forum.codejock.com/uploads/Boyd/DZ1_ResourceTest.zip - DZ1_ResourceTest.zip
|