Re: C# very optimisation



Søren Reinke wrote:

Thank you, i already use unsafe for my processing of course but i would like to know more about little optimisations now (juste like "++i" instead of "i++")

Try a profiler, and optimize the places when processing time is actually used. That way your optimizations may actually matter instead of just waste your time and make the code unreadable.


++i and i++ is not the same if used within things like calling methods and stuff like that.

more precicely, ++i and i++ are not the same when used as an expression.

Is the one considered faster than the other ?

When defining your own "operator++" the x++ variant needs to copy the old object, ++x does not.


I can't imagine that there is *any* difference whatsoever for the performance using ++i or i++ (esp. on integral types), and will continue to think that untill I see a test-program proving otherwise.

--
Helge Jensen
  mailto:helge.jensen@xxxxxxx
  sip:helge.jensen@xxxxxxx
               -=> Sebastian cover-music: http://ungdomshus.nu <=-
.



Relevant Pages

  • Re: Speed/safety trade-offs and types vs. system classes
    ...  But this doesn't matter at all. ... array will work on any CL implementation, be it running on a 17-bit ... my code (with possible optimisations) on SBCL and ECL. ...
    (comp.lang.lisp)
  • Re: which one is faster/better > or >=
    ... it's a complete waste of time even ... One thing I wanted to add was that if creating a fast algorithm then ... 1% advantage but in combination with other optimisations it could give real ... Michael ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: which one is faster/better > or >=
    ... it's a complete waste of time even ... Counting down to zero would be fairly small I agree but other ... similar optimisations can have a big difference. ...
    (microsoft.public.dotnet.languages.csharp)