Board index » Visual Studio » C++ vs. C# regarding performance

C++ vs. C# regarding performance

Visual Studio6
Hello



We are about to dive into a new application for a client. This application

is going to have database reads from multiple tables (probably just one sql

query) every 500ms or less. Once I get my results back, I need to perform

some action with those results, the quicker I get my results back, the

quicker I can peform my action. The database is MSDE and is going to reside

on the local machine.



I was wondering if anyone had any information on performance between C++ and

C#, specifically regarding database reads. Generally I have used C# and

ADO.NET for database driven applications, but performance is a real concern

here, and can be a deal breaker between C++ and C#. Please try to be as

objective as possible.



Also what technology is reccommended for connecting to an MSDE database via

C++. ADO?



Thanks.

Ryan


-
 

Re:C++ vs. C# regarding performance

"Ryan Taylor" <rtaylor@stgeorgeconsulting.com>wrote in message

Quote
We are about to dive into a new application for a client. This

application

is going to have database reads from multiple tables (probably just

one sql

query) every 500ms or less. Once I get my results back, I need to

perform

some action with those results, the quicker I get my results back, the

quicker I can peform my action. The database is MSDE and is going to

reside

on the local machine.



I was wondering if anyone had any information on performance between

C++ and

C#, specifically regarding database reads.



There's no measurable difference. It's like asking whether WriteFile is

faster when called from C++ than from any other language. The caller is

just sitting there waiting for the query to complete: the time is spent

inside the DB server and transmitting data over network, not in your

C++/C# code.



Quote
Also what technology is reccommended for connecting to an MSDE

database via

C++. ADO?



ADO is easiest to use. OLE DB is claimed to be slightly faster (ADO is a

wrapper on top of OLE DB).

--

With best wishes,

Igor Tandetnik



With sufficient thrust, pigs fly just fine. However, this is not

necessarily a good idea. It is hard to be sure where they are going to

land, and it could be dangerous sitting under them as they fly

overhead. -- RFC 1925





-

Re:C++ vs. C# regarding performance

Igor Tandetnik wrote:

Quote
"Ryan Taylor" <rtaylor@stgeorgeconsulting.com>wrote in message

>Also what technology is reccommended for connecting to an MSDE

>database via

>C++. ADO?



ADO is easiest to use. OLE DB is claimed to be slightly faster (ADO

is a wrapper on top of OLE DB).



Or for managed C++ (or C#), ADO.NET should be the fastest if you use the

System.Data.SqlClient classes as these bypass OLE-DB and go directly to the

database.



-cd







-

Re:C++ vs. C# regarding performance

"Ryan Taylor" <rtaylor@stgeorgeconsulting.com>wrote in



Quote
Hello



We are about to dive into a new application for a client. This

application is going to have database reads from multiple tables

(probably just one sql query) every 500ms or less. Once I get my

results back, I need to perform some action with those results,

the quicker I get my results back, the quicker I can peform my

action. The database is MSDE and is going to reside on the local

machine.



I was wondering if anyone had any information on performance

between C++ and C#, specifically regarding database reads.

Generally I have used C# and ADO.NET for database driven

applications, but performance is a real concern here, and can be a

deal breaker between C++ and C#. Please try to be as objective as

possible.



Also what technology is reccommended for connecting to an MSDE

database via C++. ADO?

The answer really depends on what query you're running and what are

the actions you need to perform. If your query is not some kind of

data-mining, 2 queries per second is about idle mode for most

database engines. It is very likely that the database can provide you

results in a couple of ms or something like that (except the first

time you run the query). Of course, that really depends on the query,

but it's typical for the queries people use as a poll.



Add to this time the time spent in various database layers you use

(ODBC, Ole DB, ADO etc). This overhead generally varies from

combination of the client technology and the database provider. If

you're looking for ultimate performance, you can use database

specific libraries, like Open Client for Sybase or MySQL client

library for MySQL. I don't know what's the best for MSDE though.

These consideration mostly apply to the systems with 100 of

transactions per second, so it is not likely to make much difference

in your case.



This will only leave your own code to consider and that's the only

place where your choice of the language makes difference. C++ and C#

will give identical results as long as you don't use managed

extensions, otherwise you can theoretically make faster code in C++,

but in practice, the difference you gain won't usually worth the

effort. So my advise is probably to choose whatever language you're

more comfortable with and concentrate on your algorithm.



Alex.

-

Re:C++ vs. C# regarding performance

Thanks everyone. I've got some really good information that I can present to

my superiors. They'll probably want numbers, so I'll have to write a quick

demo in both, but I know what to look for and consider in my programming.

Thanks.



Ryan





-