| View previous topic :: View next topic |
| Author |
Message |
Vincent Diepeveen
Joined: 09 Mar 2006 Posts: 1738 Location: The Netherlands
|
Post subject: Re: C# Performance Posted: Sun Feb 19, 2012 5:25 pm |
|
|
| RoadWarrior wrote: |
| diep wrote: |
'cryptographically-secure pseudo-random'
that's a huge sentence, tough to parse for me, especially for Bill Gates toylanguage.
uhhhh?
What's the difference with a RNG? |
The first difference is that a CSPRNG is designed to pass rigorous statistical randomness tests such as those in the Diehard and Dieharder suites. This gives you confidence that the numbers produced are useful in specific contexts like Zobrist hashing.
The second difference isn't applicable to chess programming, but is very important for cryptography. A CSPRNG is designed to hold up under serious attack, even when its initial or running state becomes available to an attacker.
| diep wrote: |
Optimization in C# seems more complex than in C.
Not surprisingly. Usually microbenchmarks you can keep speed difference under control. Factor 4 or so slower than well written C.
The real problem comes of course when a program grows a tad bigger.
Yet if i see the struggle here, then i'm glad i program in C |
A managed language like C# removes whole categories of bugs, such as the heap corruptions and array-index-out-of-bound errors that so often lead to frustrating late-night debugging sessions. So you can get more done with less effort, especially using the rich functionality provided by the .NET base class library.
The trade-off, however, is that you have to work further away from the hardware and with a relatively high-level language. Which means that your mental model of the language spec and the JIT compiler has to be fairly good.
Note that the list of optimisations performed by the JIT compiler is impressive given that it's done in "wall clock" time:
| Code: |
Constant folding
Constant and copy propagation
Common subexpression elimination
Code motion of loop invariants
Dead store and dead code elimination
Register allocation
Method inlining
Loop unrolling (small loops with small bodies) |
The result is comparable to traditional native code - at least in the same ballpark. I think your "factor of 4" is an exaggeration. If I'm faced with performance issues, I don't usually look at the language - I look in the mirror.  |
Mark, the chessprogrammers aren't beginners. Stuff like out of bounds you have boundscheckers for. The fact that default C# is doing automatic boundschecking slows down the language bigtime, i don't see it as an advantage of the language for low level codes like game tree search where you put in a lot of time per line of code and try to regurarly optimize what you wrote before.
In fact it's no secret my code runs in C on many different platforms, yet if i see how total inefficient most compilers, even in C, deal with the code, the only problem in low level development is the quality of the compilers.
Now where compared to all other languages C/C++ compilers are pretty decent by any standard, they are not for any other language.
Even then the mistakes i see the C/C++ compilers make is huge.
C++ code of c ourse i only mention because it CAN be similar to C. Not because it practically is. Maybe 1 or 2 coders on the planet manage to write C++ same speed, practical the rest is factors slower.
Just the nature of object oriented languages already implicitly forces you to subclass everything and make new classes, using a number of layers of classes already assures you of the huge slowdown of course, which imperative languages like C and Fortran do not have.
The thing that caused JAVA and C# to be there IMHO is the clumsy and total nerd manner how they've 'standardized' C++ at ISO. It took till 1999 or so and they have allowed too much and just have kept adding to it, with too many nerd features, making it worlds most complex language.
Just 0 business sense. Then Java came there by Sun years before they managed to finalize an iso in C++ (which was a total messed up ISO of course if you look from it from a company viewpoint that wants to get things done). Java so called had no pointers and only single inheritence.
The initial compilers for it were a crap.
It rescued Sun for a few years, and by now we know that java has outlived Sun.
m$ then responded with C# onto Java.
C# would never have existed without Java having seen the light.
Java would not have been there i guess if they would've been more decisive about C++.
That's why we have the mess right now as it is.
Vincent
p.s. i don't want this to end up in a yes/no between languages, but we have to face reality that C# and Java are of similar speed, about 3x slower than C if both get written by excellent programmers, for larger pieces of code.
That is - if your C# and Java isn't gonna defragment the memory while your proggie is running
Note that for company codes, which are massive the difference is bigger. Usually a 100+. However we also must note that C is not a nice language from company viewpoint to manage when you have many programmers of varying experience in programming. |
|
| Back to top |
|
 |
|
| Subject |
Author |
Date/Time |
C# Performance |
Richard Allbert |
Fri Jan 27, 2012 8:41 pm |
Re: C# Performance |
Kevin Hearn |
Fri Jan 27, 2012 9:01 pm |
Re: C# Performance |
Richard Allbert |
Fri Jan 27, 2012 9:13 pm |
Re: C# Performance |
Gary |
Fri Jan 27, 2012 9:07 pm |
Re: C# Performance |
Richard Allbert |
Fri Jan 27, 2012 9:17 pm |
Re: C# Performance |
Gary |
Fri Jan 27, 2012 10:09 pm |
Re: C# Performance |
Mark Pearce |
Sat Jan 28, 2012 12:59 am |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 8:44 am |
Re: C# Performance |
Sven Schüle |
Sat Jan 28, 2012 9:48 am |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 10:25 am |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 11:41 am |
Re: C# Performance |
Mark Pearce |
Sat Jan 28, 2012 11:44 am |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 10:31 am |
Re: C# Performance |
Marco Costalba |
Sat Jan 28, 2012 1:09 pm |
Re: C# Performance |
Lucas Braesch |
Sat Jan 28, 2012 1:52 pm |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 2:05 pm |
Re: C# Performance |
Marco Costalba |
Sat Jan 28, 2012 2:30 pm |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 5:22 pm |
Re: C# Performance |
Sven Schüle |
Sat Jan 28, 2012 6:02 pm |
Re: C# Performance |
Richard Allbert |
Sat Jan 28, 2012 6:12 pm |
Re: C# Performance |
Robert Purves |
Sat Jan 28, 2012 10:17 pm |
Re: C# Performance |
Marco Costalba |
Sat Jan 28, 2012 10:25 pm |
Re: C# Performance |
Thomas Petzke |
Sat Jan 28, 2012 4:21 pm |
Re: C# Performance |
Richard Allbert |
Mon Jan 30, 2012 12:52 pm |
Re: C# Performance |
Marco Costalba |
Mon Jan 30, 2012 6:37 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 01, 2012 6:55 pm |
Re: C# Performance |
Marco Costalba |
Wed Feb 01, 2012 7:18 pm |
Re: C# Performance |
Mark Pearce |
Mon Jan 30, 2012 9:55 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 01, 2012 6:57 pm |
Re: C# Performance |
Mark Pearce |
Wed Feb 01, 2012 9:59 pm |
Re: C# Performance |
Mark Pearce |
Fri Feb 03, 2012 1:34 am |
Re: C# Performance |
Robert Purves |
Fri Feb 03, 2012 3:26 am |
Re: C# Performance |
Mark Pearce |
Fri Feb 03, 2012 9:28 am |
Re: C# Performance |
Sven Schüle |
Fri Feb 03, 2012 9:45 am |
Re: C# Performance |
Mark Pearce |
Sat Feb 04, 2012 7:57 pm |
Re: C# Performance |
Sven Schüle |
Sat Feb 04, 2012 10:36 pm |
Re: C# Performance |
Mark Pearce |
Sat Feb 04, 2012 11:49 pm |
Re: C# Performance |
Sven Schüle |
Sun Feb 05, 2012 12:51 am |
Re: C# Performance |
Mark Pearce |
Sun Feb 05, 2012 1:05 am |
Re: C# Performance |
Sven Schüle |
Fri Feb 03, 2012 10:04 am |
Re: C# Performance |
Mark Pearce |
Fri Feb 03, 2012 11:40 am |
Re: C# Performance |
Richard Allbert |
Sat Feb 04, 2012 7:10 pm |
Re: C# Performance |
Lucas Braesch |
Sat Feb 04, 2012 8:31 pm |
Re: C# Performance |
Mark Pearce |
Sat Feb 04, 2012 10:23 pm |
Re: C# Performance |
Mark Pearce |
Sun Feb 05, 2012 12:23 am |
Re: C# Performance |
Lucas Braesch |
Sun Feb 05, 2012 2:57 am |
Re: C# Performance |
Mark Pearce |
Sun Feb 05, 2012 11:40 am |
Re: C# Performance |
Richard Allbert |
Mon Feb 06, 2012 6:29 pm |
Re: C# Performance |
Richard Allbert |
Mon Feb 06, 2012 6:29 pm |
Re: C# Performance |
Richard Allbert |
Mon Feb 06, 2012 6:30 pm |
Re: C# Performance |
Richard Allbert |
Mon Feb 06, 2012 6:45 pm |
Re: C# Performance |
Gary |
Mon Feb 06, 2012 7:00 pm |
Re: C# Performance |
Richard Allbert |
Mon Feb 06, 2012 7:12 pm |
Re: C# Performance |
Sven Schüle |
Mon Feb 06, 2012 10:50 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:52 am |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:53 am |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:53 am |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:54 am |
Re: C# Performance |
Mark Pearce |
Tue Feb 07, 2012 1:59 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 2:54 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 3:06 pm |
Re: C# Performance |
Mark Pearce |
Tue Feb 07, 2012 5:17 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 6:10 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 6:20 pm |
Re: C# Performance |
Mark Pearce |
Tue Feb 07, 2012 8:02 pm |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:19 pm |
Re: C# Performance |
Mark Pearce |
Tue Feb 07, 2012 10:20 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 7:47 am |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 7:57 am |
Re: C# Performance |
Sven Schüle |
Wed Feb 08, 2012 10:09 am |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 12:16 pm |
Re: C# Performance |
Vincent Diepeveen |
Sat Feb 18, 2012 10:03 pm |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 9:30 am |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 12:02 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 12:34 pm |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 12:56 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 1:18 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 2:30 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 2:34 pm |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 3:02 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 3:27 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 3:29 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 3:59 pm |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 4:04 pm |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 6:07 pm |
Re: C# Performance |
Richard Allbert |
Thu Feb 09, 2012 10:41 am |
Re: C# Performance |
Mark Pearce |
Thu Feb 09, 2012 1:47 pm |
Re: C# Performance |
Richard Allbert |
Thu Feb 09, 2012 2:56 pm |
Re: C# Performance |
Mark Pearce |
Sat Feb 11, 2012 4:41 pm |
Re: C# Performance |
Richard Allbert |
Sun Feb 12, 2012 8:34 am |
Re: C# Performance |
Lucas Braesch |
Sun Feb 12, 2012 10:52 am |
Re: C# Performance |
Richard Allbert |
Sun Feb 12, 2012 12:26 pm |
Re: C# Performance |
Ron Murawski |
Mon Feb 13, 2012 5:26 am |
Re: C# Performance |
Lucas Braesch |
Mon Feb 13, 2012 5:52 am |
Re: C# Performance |
Richard Allbert |
Mon Feb 13, 2012 6:27 am |
Re: C# Performance |
Ron Murawski |
Tue Feb 14, 2012 6:38 am |
Re: C# Performance |
Lucas Braesch |
Tue Feb 14, 2012 8:22 am |
Re: C# Performance |
Mark Pearce |
Tue Feb 14, 2012 11:30 pm |
Re: C# Performance |
Richard Allbert |
Thu Feb 16, 2012 10:49 am |
Re: C# Performance |
Mark Pearce |
Sat Feb 18, 2012 12:34 pm |
Re: C# Performance |
Richard Allbert |
Mon Feb 20, 2012 9:19 pm |
Re: C# Performance |
Mark Pearce |
Tue Feb 21, 2012 8:33 am |
Re: C# Performance |
Richard Allbert |
Tue Feb 21, 2012 6:37 pm |
Re: C# Performance |
Vincent Diepeveen |
Sat Feb 18, 2012 10:19 pm |
Re: C# Performance |
Mark Pearce |
Sun Feb 12, 2012 2:01 pm |
Re: C# Performance |
Richard Allbert |
Sun Feb 12, 2012 4:40 pm |
Re: C# Performance |
Vincent Diepeveen |
Sat Feb 18, 2012 10:06 pm |
Re: C# Performance |
Mark Pearce |
Sun Feb 19, 2012 1:01 pm |
Re: C# Performance |
Vincent Diepeveen |
Sun Feb 19, 2012 5:25 pm |
Re: C# Performance |
Mark Pearce |
Sun Feb 19, 2012 7:04 pm |
Re: C# Performance |
Vincent Diepeveen |
Sun Feb 19, 2012 9:17 pm |
Re: C# Performance |
Mark Pearce |
Sun Feb 19, 2012 11:33 pm |
Re: C# Performance |
Richard Allbert |
Sun Feb 19, 2012 9:22 pm |
Re: C# Performance |
Vincent Diepeveen |
Sun Feb 19, 2012 9:32 pm |
Re: C# Performance |
Vincent Diepeveen |
Sun Feb 19, 2012 9:37 pm |
Re: C# Performance |
Vincent Diepeveen |
Sun Feb 19, 2012 10:06 pm |
Re: C# Performance |
Lucas Braesch |
Wed Feb 08, 2012 10:56 am |
Re: C# Performance |
Mark Pearce |
Wed Feb 08, 2012 11:30 am |
Re: C# Performance |
Richard Allbert |
Wed Feb 08, 2012 12:04 pm |
Re: C# Performance |
Tony Soares |
Tue Feb 07, 2012 3:47 am |
Re: C# Performance |
Richard Allbert |
Tue Feb 07, 2012 9:55 am |
Re: C# Performance |
Mark Pearce |
Sat Feb 04, 2012 8:37 pm |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|