PC Review


Reply
Thread Tools Rate Thread

C# Performance Problem

 
 
badrbadr
Guest
Posts: n/a
 
      27th Aug 2006
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

 
Reply With Quote
 
 
 
 
chanmm
Guest
Posts: n/a
 
      28th Aug 2006
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

"badrbadr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Bill Butler
Guest
Posts: n/a
 
      28th Aug 2006
"badrbadr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Performance Counter performance problem in Windows Service application Tomasz Jastrzebski Microsoft Dot NET Framework 8 23rd Oct 2006 09:35 AM
performance problem TeunSpaans Microsoft Access 0 28th Aug 2006 02:41 PM
Performance problem Matthew Windows XP Performance 1 9th Feb 2004 04:31 PM
Performance Problem Jannoth Windows XP Performance 1 6th Feb 2004 04:17 PM
Performance Problem Darren Windows XP Help 1 5th Dec 2003 06:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.