Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

C# Performance Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
badrbadr - 27 Aug 2006 22:18 GMT
Hi,
Today, I find a problem from an old Google Code Jam Contest.
You can read the problem statement here :
http://www3.sympatico.ca/red.zrari/problem.htm

I solved the problem in 15 min (wow, c# is very productive but...) but
my program takes a long time (1 min 15 sec) to solve the example 5 (see
the problem statement).
I found a C++ program that uses the same method than my program.
However, this program is a lot faster : it solves the example 5
in...0sec.

I can't understand why my C# program takes more than 1 minutes since
they use the same method.

The link to my C# program source code :
http://www3.sympatico.ca/red.zrari/csharp.htm
The link to the C++ program source code :
http://www3.sympatico.ca/red.zrari/c++.htm

Man, it's really embarrassing -_-
Hope it's my fault and not the .net framework fault.

My PC Configuration:
     - AMD Athlon XP 2800+
     - Windows XP Pro SP2
     - .Net framework 2.0
     - Visual C# Express 2005 and Visual C++ Expresss 2005
chanmm - 28 Aug 2006 05:25 GMT
The code are somehow different C++ using STL and pointer "vector<point> &vp"
for example. So you should look at the generic class in C# too.

chanmm

> Hi,
> Today, I find a problem from an old Google Code Jam Contest.
[quoted text clipped - 24 lines]
>      - .Net framework 2.0
>      - Visual C# Express 2005 and Visual C++ Expresss 2005
Bill Butler - 28 Aug 2006 11:45 GMT
> Hi,
> Today, I find a problem from an old Google Code Jam Contest.
[quoted text clipped - 19 lines]
> Man, it's really embarrassing -_-
> Hope it's my fault and not the .net framework fault.

I suggest that you verify that both versions are actually answering the
same question (they're not). Take a close look at your short circuit
execution in both cases (that is where you return -1). Next, take a look
at your bounds on the C++ version.
   I don't understand why the C++ version look so different from the C#
version. There is no reason that you couldn't get them much more similar
in behavior. For instance, you don't even declare a class in the C++
version. If you wish to get a realistic comparison between languages,
you really need to make sure that both programs are doing the SAME
thing.

Good luck,
   Bill

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.