473,414 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

C# Performance Problem

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

Aug 27 '06 #1
2 1349
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" <ba********@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
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

Aug 28 '06 #2
"badrbadr" <ba********@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
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

Aug 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve_CA | last post by:
Hello all, I've been recruited to assist in diagnosing and fixing a performance problem on an application we have running on SQL Server 7. The application itself is third party software, so we...
0
by: Andrew Mayo | last post by:
This problem was discovered with MSDE2000 SP2 and under WinXP SP2. We are unsure whether it is more widespread as it has only been seen on one machine to date. The problem is related to name...
6
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of...
4
by: Martin | last post by:
I am using graphics as backgrounds for forms,buttons,labels etc. The question is: is it faster to load all graphics from files on app start or to use it embeded (places in editor during design)....
13
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
17
by: 57R4N63R | last post by:
I'm currently building a website for one of the client. There has been few errors here and there, but just recently the problem is getting worse. Basically the symptoms is that when the user try...
8
by: NAdir | last post by:
Hi, thank you for your help. My VB.Net application contains a document that the user can refresh at any time. The refresh works fine and needs to loop through few datatables (hundreds of rows)....
1
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.