Board index » cppbuilder » Odd performance problems with ActiveX controls, Please help

Odd performance problems with ActiveX controls, Please help

 Hello All,

I have been trying to use a graphing component from National Instruments
to plot data.  I installed it into my project, and it seems to work
find, except for one little thing.  The more data I plot, the slower it
goes.  In other words, if I plot one set of points, it might take 1ms.
If I press a button and plot the same set of points again, it might take
1.05ms.  Then 1.1ms, 1.15ms, and so on forever.  This makes the control
useless after a few thousand plots.

 I thought this was a problem with National Instruments' control,
except:

1) I can run the same code in VC++ 6.0, and it works fine (no slowdown)
2) I can run the same code (ported) in VB, and it works fine
3) I have had the same problem with other controls

I also tried switching to a strip chart control from General Majic Corp
(yes, that's how they spell "Majic").  I get the same problem with a
GreenLeaf serial port control ActiveX library when flipping bits on the
serial port (see code snippet below).  

Here is a simple code example using the GreenLeaf serial port control to
flip the DTR bit on COMM1 (you can ignore my DebugTimer calls, as the
problem is the same even when they are removed):

void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
   PortCtl1->Open(); // this function opens the serial port

   DebugTimer profiler;
   profiler.Start("Beginning loop");  // log the current time

   int state = 0;
   for (int i = 0; i < 200; i++)
   { // THIS LOOP TAKES LONGER AND LONGER EACH TIME THROUGH!

      state = !state;
      PortCtl1->Dtr = state;  // <<== set a property on the activeX
control, this line Gets SLOW
      profiler.TimeCheck("in loop");  // log how long it took for this
iteration

   }

   profiler.TimeCheckAndStop("Done loop"); // log the end time
   PortCtl1->Close(); // close the serial port

Quote
}

When I re-wrote this code using the windows API functions to set the DTR
bit, it ran at the same speed the first time through the loop, but was
going 100x faster by the last iteration.

I would be VERY appreciative if anybody has any suggestions.  Right now,
it looks like I may have to reimplement my application in visual
basic... not a pretty thought.

I did try an example like the one above with some of the chart and
spreadsheet controls that come with Builder, and did not get the same
slowdown.  I am using Windows2000 with service pack1, and C++Builder
version 5 with the latest patches.

Please help!

-Peter

 

Re:Odd performance problems with ActiveX controls, Please help


Peter, search this group ( www.deja.com ) as NI controls were discussed
here quite a bit.

.a

Quote
Peter Jensen wrote:

[snip]

Re:Odd performance problems with ActiveX controls, Please help


You might also want to try Iocomp's High-Speed strip Chart component...
http://www.iocomp.com

Patrick Carroll

Quote
"Peter Jensen" <jen...@cogbio.com> wrote in message

news:39CEA828.799CA895@cogbio.com...
Quote

>  Hello All,

> I have been trying to use a graphing component from National Instruments
> to plot data.  I installed it into my project, and it seems to work
> find, except for one little thing.  The more data I plot, the slower it
> goes.  In other words, if I plot one set of points, it might take 1ms.
> If I press a button and plot the same set of points again, it might take
> 1.05ms.  Then 1.1ms, 1.15ms, and so on forever.  This makes the control
> useless after a few thousand plots.

>  I thought this was a problem with National Instruments' control,
> except:

> 1) I can run the same code in VC++ 6.0, and it works fine (no slowdown)
> 2) I can run the same code (ported) in VB, and it works fine
> 3) I have had the same problem with other controls

> I also tried switching to a strip chart control from General Majic Corp
> (yes, that's how they spell "Majic").  I get the same problem with a
> GreenLeaf serial port control ActiveX library when flipping bits on the
> serial port (see code snippet below).

> Here is a simple code example using the GreenLeaf serial port control to
> flip the DTR bit on COMM1 (you can ignore my DebugTimer calls, as the
> problem is the same even when they are removed):

> void __fastcall TForm1::BitBtn1Click(TObject *Sender)
> {
>    PortCtl1->Open(); // this function opens the serial port

>    DebugTimer profiler;
>    profiler.Start("Beginning loop");  // log the current time

>    int state = 0;
>    for (int i = 0; i < 200; i++)
>    { // THIS LOOP TAKES LONGER AND LONGER EACH TIME THROUGH!

>       state = !state;
>       PortCtl1->Dtr = state;  // <<== set a property on the activeX
> control, this line Gets SLOW
>       profiler.TimeCheck("in loop");  // log how long it took for this
> iteration

>    }

>    profiler.TimeCheckAndStop("Done loop"); // log the end time
>    PortCtl1->Close(); // close the serial port
> }

> When I re-wrote this code using the windows API functions to set the DTR
> bit, it ran at the same speed the first time through the loop, but was
> going 100x faster by the last iteration.

> I would be VERY appreciative if anybody has any suggestions.  Right now,
> it looks like I may have to reimplement my application in visual
> basic... not a pretty thought.

> I did try an example like the one above with some of the chart and
> spreadsheet controls that come with Builder, and did not get the same
> slowdown.  I am using Windows2000 with service pack1, and C++Builder
> version 5 with the latest patches.

> Please help!

> -Peter

Other Threads