Given of course that both come in a TO-220 case. I wouldn't think so, right? I try to make it out from the K/W ratings but they seem to vary wildly from manufacturer to manufacturer. Anybody knows the answer?


Question: Is there any performance difference between ++i and i++ in C#?
Answer: Ah... Open again.  OK. Here's the deal.

ILDASM is a start, but not an end.  The key is: What will the JIT generate for assembly code?

Here's what you want to do.

Take a couple samples of what you are trying to look at.  Obviously you can wall-clock time them if you want - but I assume you want to know more than that.

Here's what's not obvious.  The C# compiler generates some MSIL sequences that are non-optimal in a lot of situations.  The JIT it tuned to deal with these and quirks from other languages.  The problem: Only 'quirks' someone has noticed have been tuned.

You really want to make a sample that has your implementations to try, returns back up to main (or wherever), Sleep()s, or something where you can attach a debugger, then run the routines again.

You DO NOT want to start the code under the debugger or the JIT will generate non-optimized code - and it sounds like you want to know how it will behave in a real environment.  The JIT does this to maximize debug info and minimize the current source location from 'jumping around'.  Never start a perf evaluation under the debugger.

OK.  So once the code has run once (ie: The JIT has generated code for it), then attach the debugger during the sleep (or whatever).  Then look at the x86/x64 that was generated for the two routines.

My gut tells me that if you are using ++i/i++ as you described - ie: in a stand alone expression where the rvalue result is not re-used - there won't be a difference.  But won't it be fun to go find out and see all the neat stuff! :)