LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-22-2009, 02:22 PM   #1
bhtawfik
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
C++ code run from windows is slower than cygwin


Hello everyone, I had a C++ code run under cygwin, when I modified this code to run it under windows (Visual C++ 2003) the code runs very slowly, 7 time slower. anyone have an idea about how to solve this problem?
 
Old 10-22-2009, 02:24 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Check your optimization settings
 
Old 10-22-2009, 02:40 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by bhtawfik View Post
(Visual C++ 2003) the code runs very slowly, 7 time slower. anyone have an idea about how to solve this problem?
Which Visual C++ 2003?
Did you buy it, or is that one of the free Express Editions?

The Express Editions I have used are anti optimized (I assume on purpose to make serious users buy the expensive version) so programs generated with the Express Edition run very slow.

There are many reasons I can think of why you might want to switch from Cygwin to Visual C++. If we knew which reason, we might give better advice.

For most such reasons, switching to Mingw would be easier and better than the Express Edition of Visual C++, maybe even better than the expensive Visual C++.

BTW, do you use 32 bit or 64 bit Windows? If you use 64 bit Windows, I suggest 64 bit Mingw. The 32 bit Mingw generates code with better performance than 32 bit Visual C++ Express, but significantly worse than 32 bit Visual C++ professional. The 64 bit Mingw generates code that is much more performance competitive against almost any compiler.
 
Old 10-23-2009, 08:00 AM   #4
bhtawfik
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you all, I have the full version of microsoft visual studio.net 2003. I want to run this code under windows to add it to a larger program run under windows.
what kind of optimization can I change to speed it up?
 
Old 10-23-2009, 09:29 AM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I only have 1998 and 2005 handy at the moment. MS seems to change where they hide such settings in each release. So I'm not sure where it is in the 2003 version.

First make sure you are doing a release build, not a debug build. It is very hard to get optimization working in a debug build and very hard to debug with optimizations enabled (for various reasons, I usually do debug fully optimized builds, but only because I have no choice. I don't recommend debugging optimized builds if you have a choice).

I expect a high level of optimization is the default in a release build, so once you select a release build you're probably OK.

But check the optimization level by going to the project properties (or settings or whatever it was called in the 2003 version) and selecting the C/C++ folder and the optimization sub folder and then make some good guesses what the choices there mean.

BTW, why ask for Visual Studio help in a Linux forum?

BTW2, functions, DLLs, and programs build with Mingw can be freely mixed with those built with Windows C/C++ compilers, including Visial C++. So if you do have code that Visual C++ won't compile decently (unlikely) then Mingw (unlike Cygwin) is a solution to your goal of being able to add the result to a larger program.

Quote:
Originally Posted by bhtawfik View Post
I modified this code to run it under windows (Visual C++ 2003)
But with vague statements like that, there are always plenty of other possibilities for the cause of the problem. Maybe the optimization is OK or irrelevant and it was your modifications that made the code slower. You've told us so little that most of what we can tell you is just guesses.

Last edited by johnsfine; 10-23-2009 at 09:35 AM.
 
Old 10-23-2009, 09:52 AM   #6
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Well, the major thing is to check if you have *any* optimizations turned on at all. By default for Debug mode there's no optimizations. That's not really bad since optimizations can interfere with debugging, but not so good for performance comparisons. You should use Release with full optimizations. If you have been using Release with full optimizations, well, you might be able to tweak the optimizer with some command-line options..

Or alternatively, optimize the code itself and get boosts overall.

Ninja'd!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I cannot run my code in red hat 9.0,while in windows xp it can wzk6_3_8 Programming 11 05-21-2006 09:55 AM
convert a qt designer code in linux to run in windows shaj4848 LinuxQuestions.org Member Success Stories 0 07-27-2005 01:29 AM
How to run cygwin-X? bruno buys Linux - Software 2 09-16-2004 12:20 AM
Link DLL with C code on Win32 (CygWin) jpbarto Programming 4 10-23-2003 02:30 PM
codes run slower on the faster machine xudeyong Programming 12 05-03-2003 05:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration