The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

C++ performance with Windows Forms

I wrote an application in VS2005 C++ as a console app. On input file X it takes 3 seconds to run.

Then, I made a new project in VS2005 using CLR and windows forms. I made a GUI and copied the console app code over so that when I click a button, it runs the same code on the same input. However, it now takes about 55 seconds.

Ideas?
Mike
Friday, May 04, 2007
 
 
Run it as a console app.
Bob
Friday, May 04, 2007
 
 
Obviously something's very wrong with your translation of the console code to the windowed code, but without knowing the code I can't imagine what it is...
Chris Nahr Send private email
Friday, May 04, 2007
 
 
This probably happens when you put up a progress bar in the GUI app and the painting of the progress bar is taking more time than the actual task at hand.  Stagger the painting to atleast 1 sec intervals or remove the progress altogether.

Just guessing...
Donald Duck
Friday, May 04, 2007
 
 
Is it a CLR or Win32 console app?

If it's Win32, then you need to account for the CLR in the GUI app.
*myName
Friday, May 04, 2007
 
 
Loading the CLR takes maybe 2-3 seconds even with a cold start. That can't be the major reason why the app takes nearly a minute to run.
Chris Nahr Send private email
Friday, May 04, 2007
 
 
I assume you were writing to the console whilst processing the file and you are now writing to a text box or something similar.
Adrian
Friday, May 04, 2007
 
 
All timings are from calling _ftime_s around a specific function.

I found something interesting:

If I run it in release mode from visual studio, it takes 55 seconds.

However if I just run it from the release executable that it created, the time is about 3 seconds.

I thought these two methods were equivalent.
Mike
Friday, May 04, 2007
 
 
Visual Studio must still be mixed in there (attached to the process) because you can set break points in a release build.  I've seen similar slow downs.
Doug
Friday, May 04, 2007
 
 
Have you checked following option?
Visual Studio -> Tools -> options -> Debugging -> "suppress JIT optimizations on module load"
WildTiger Send private email
Friday, May 04, 2007
 
 
Are you using OutputDebugString anywhere in your main loop? Visual Studio's handling of this is famously poor, and a 30x slowdown doesn't sound unreasonable.

The other suggestions are also worth looking into of course!
Tom_
Sunday, May 06, 2007
 
 
Mike,

When you run in release mode on Visual Studio, it still hooks onto your program and has all the associated costs with it.

If you want a pure run-time, you have to use the Detach from Debugger or the Run without Debugger option (can't remember exact wording).

Monday, May 07, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz