| Someone wrote in |
Re: C# Linux timings
"C# Mono is usually slower"
That's right (and not only usually but nearly always). But they are getting faster and faster with each version. Since they changed the JIT from a tree-based internal representation to the new linear IR things got faster and still will ( http://www.mono-project.com/Linear_ IL ).
"... its GC is much more primitive, etc."
Sure, because at the moment they still use the same conservative Boehm-Demers-Wiser Conservative Garbage Collector like the D programming language which is far from optimal for this kind of stuff (like it is for D). But they are since a long time working on a new garbage collector ( http://mono-project.com/Compacting_ GC ) to fix this (i would like to see this for the D programming language too).
"At the moment I am not much interested in trying mono on Linux."
Oh that's a really a pity. It would lessen the C# windows-only view (even if a lot of people don't like this). Then i have to do it myself again :-(
"I have now set all classes in the C# code as sealed, but the performance is exactly the same. I don't know why."
I don't know why too. But at least it did not change the amount of inlining which the jit does (methods in sealed classes have a greater chance of getting inlined since they can't be virtual but on the other hand it is the default behaviour for methods in C# anyway, since methods are final by default (which is really better) ).
But you can always use reflector ( http://reflector.red-gate.com/Downl oad.aspx ) and look at the generated bytecode / decompiled c# code (with reflector decompiled code so you can see what the compiler has made out of your code and how / if he has optimized things). It's really interesting to see what the compiler does to your code and how things are translated.
"Turning those classes into structs may be a bit too much work now."
No it isn't (at least if you do it the primitive way). You just have to change the "class" keyword to "struct". That is basically all you have to do (no other changes - structs are instantiated with new like objects, so again no changes here). Now the structs are generated on the stack (which creates no garbage and let's the garbage collector alone which is really nice and can be a lot faster) and not on the heap anymore and they are now passed by value not by reference which can be slower. But to change this you just have to pass them by reference via the ref keyword (function parameters have to be declared as ref too)). Of course to do it optimal you really would have to think about to which classes this behaviour would make sense.
But for a quick and dirty try out by just changing the classes to structs just to see if things change it should be done quickly ...
"C# Mono is usually slower"
That's right (and not only usually but nearly always). But they are getting faster and faster with each version. Since they changed the JIT from a tree-based internal representation to the new linear IR things got faster and still will ( http://www.mono-project.com/Linear_
"... its GC is much more primitive, etc."
Sure, because at the moment they still use the same conservative Boehm-Demers-Wiser Conservative Garbage Collector like the D programming language which is far from optimal for this kind of stuff (like it is for D). But they are since a long time working on a new garbage collector ( http://mono-project.com/Compacting_
"At the moment I am not much interested in trying mono on Linux."
Oh that's a really a pity. It would lessen the C# windows-only view (even if a lot of people don't like this). Then i have to do it myself again :-(
"I have now set all classes in the C# code as sealed, but the performance is exactly the same. I don't know why."
I don't know why too. But at least it did not change the amount of inlining which the jit does (methods in sealed classes have a greater chance of getting inlined since they can't be virtual but on the other hand it is the default behaviour for methods in C# anyway, since methods are final by default (which is really better) ).
But you can always use reflector ( http://reflector.red-gate.com/Downl
"Turning those classes into structs may be a bit too much work now."
No it isn't (at least if you do it the primitive way). You just have to change the "class" keyword to "struct". That is basically all you have to do (no other changes - structs are instantiated with new like objects, so again no changes here). Now the structs are generated on the stack (which creates no garbage and let's the garbage collector alone which is really nice and can be a lot faster) and not on the heap anymore and they are now passed by value not by reference which can be slower. But to change this you just have to pass them by reference via the ref keyword (function parameters have to be declared as ref too)). Of course to do it optimal you really would have to think about to which classes this behaviour would make sense.
But for a quick and dirty try out by just changing the classes to structs just to see if things change it should be done quickly ...