|
This is like challenging a boxing champion to an arm-wrestling competition and then find him wanting.
The speed of C++ is not tested by printing into stdout. Do some processing that doesn't involve printing repeatedly into console.
For example, calculate the largest 10 digit prime by traversing a 5x5 number matrix. Then compare the speed.
|
|
|
|
|
|
"my tests shows c# is faster than c++"
No they don't. You showed that ONE C# program ran faster than ONE C++ program.
Sheesh.
|
|
|
|
|
Hi,
I compiled and ran the program at home using g++.
The printing version was 5.6 seconds and a non printing version was 4.62 seconds.
much better than both those times.
C# also has the overhead on the .NET runtime.
And the C++ program just has the c++ standary libray for overhead.
c++ is fully compiled and c# is tokenized and still needs to be processed by the JIT.
|
|
|
|
|
std::endl is not equivalent to '\n' but also flushes the buffer. Try to change endl by '\n'
|
|
|
|
|
Muharrem B. wrote: Everyone says c++ is faster than c#, why?
Because "everyone" doesn't know what they are talking about when then make a statement like that.
First of course in pantheon of programming speed is of small consequence. Microsoft, google and apple are not successful because of speed but rather because they make money. Businesses that don't make money do not last. And developers that think technology is more important than sales end up working for companies that don't make money.
Second of course there can be actual business reasons where 'speed' is important but in the vast, vast majority of cases actually producing speed is based on factors besides just code and language.
Third when in fact something needs to be faster it is experience not code that actually leads to faster solutions. Someone with years of experience is much more likely to produce a 'fast' system than someone without that experience regardless of technology choice. Keep in mind however that that is an average an not an absolute.
Fourth, benchmarks, which is what you have, is pretty much useless in determining speed as far as it means anything in the business world. They often reflect nothing but one small aspect of the language and platform on which they run. That is if they are down well. Poorly done they often reflect a misunderstanding of how languages, platforms and even benchmarks work. Very rarely they even reflect a biased attempt to achieve a specific result.
Fifth if one really wants to actually focus on professional programming then one should focus on understanding the basics on what it means to create a system and not language specifics.
Basic one would be to understand that performance is impacted in the following way
1. Requirements, most impact
2. Design (including explicit and implicit.)
3. platform
4. language least impact
Basic two would be to understand that if one wants to get more performance out of an application (not a system) and one can only focus on 4 in the above then one must do the following
1. Learn how to use an application profiler
2. Learn how to simulate real business data in the application
3. Run the profiler and determine where it might actually be possible to improve performance.
Focusing on 1/2 in the above can achieve orders of magnitude impacts on performance while 4 can only achieve marginal percentage increases.
After all of that my personal opinion is that if one had an unlimited amount of time, if there was an optimal design and requirements, if two programmers were very, very experienced with similar backgrounds in application design and the application was limited to a very narrow subset of functionality then it is possible that the C++ programmer might produce a solution that is marginally faster than the C# programmer.
But since that is a complete fantasy which has nothing to do with reality it is pointless to discuss it.
|
|
|
|
|
Because its not.
1) Did you run with the debugger attached?
2) Did you build in "release" configuration?
3) Are the builds both running in x86 or x64?
4) What C++ and C#/.NET compiler are you using?
Almost nothing is faster in C# when doing numerical calculations like this.
Usually only stuff where the GC has some kind of benefit in performance be delaying de-allocation.
|
|
|
|
|
C# or rather the .Net runtime does a number of things to make code "safer". These are things like bounds checking, type safety, etc. Some of that happens at compile time, but of necessity a lot of it happens at run time. This obviously takes time. Much of it can be "turned off" if you want to though you may not want to. If you want very tight control of timing then C++ and likely straight C is a better bet. For a variety of problems .Net (and therefore C#) is performant enough and "safer" than C or C++. It is good to have options.
Pat O
|
|
|
|
|
If you can manage it, never-ever work with Telerik!!!
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Yeah.
He's too lazy, that bloke - and he never refills the coffee machine when he takes the last cup.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
But if you do and you get stuck, please don't ask questions on Telerik's own forums that are packed with people who know a lot about Telerik
|
|
|
|
|
The problem that those payed to support you don't know nothing...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Just to rub it in a bit, my experience with DevExpress is quite different.
|
|
|
|
|
Kornfeld Eliyahu Peter wrote: don't know nothing
Well, I should hope not. If I paid for support and the support technicians did know nothing, I'd be pretty annoyed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Our shop is in the process of not using Telerik controls anymore. We are looking for something more lightweight and open source.
|
|
|
|
|
Tell me about it. The project I'm working on now has a bunch of Telerik controls being used in ways that are uncharted territory as far as The Great Google is concerned.
We've also found a sh*t-ton of bugs and a couple of things that were badly implemented, like using local storage for storing data for off-line grids instead of using session storage. That was a fun little bug to find that only occurs when you've got multiple tabs going to the same page with different data!
|
|
|
|
|
We use them extensively, both the Silverlight and now the WPF versions. While they can be difficult sometimes and I dare not try and change their styling they do work well.
We changed from Infragistics who have had an absolutely horrendous object hierarchy.
SO seems to be their main support tool these days but I have had some real nasties resolved by their support team. I do like their habit of supplying a sample program to demonstrate their solutions.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I got it from my father, who got it form his uncle, who got it from his father (not my grandfather)...
Logarléc[^]
(The image is not that of mine, but it's from the very same line...)
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
modified 2-Feb-16 5:37am.
|
|
|
|
|
Argghhh! You beat me by 63 years!
A real family heirloom. Nice!
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
And how many instructions per hour ?
modified 19-Jan-21 21:04pm.
|
|
|
|
|
In my best shape I can do 5 per minutes...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Thank you sir, I learnt the very existance of it. This gives me many ideas for D&D adventures...
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
"When you have eliminated the JavaScript, whatever remains must be an empty page." -- Mike Hankey
If a coffee bean is between the Earth and the Sun, is it a Java Eclipse? -- Sascha Lefèvre
/xml>
|
|
|
|
|
The evil logarlec laughed "you fools! you can't even begin to comprehend my power!"
You roll two dice and the logarlec overflows.
The end.
|
|
|
|
|
oh I remember, I learned it in the school.
and it works without a battery.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I have one of these[^], it's a pocket calculator.
|
|
|
|