Significant elapsed time differences when calling sort() on different Comparable implementations

All, I'm sorry to have wrapped everyone's minds around this today. It was definitely Apex logging levels that was corrupting my results, and now I feel slightly dumb and ever slightly more educated. With very little logging enabled (just enough to debug results & profiling), results are now very consistently the same across all implementations.

Thanks to @DanielBallinger for suggesting I look at logging levels.

Lesson learned: logging levels greatly impact performance of Apex code, and in some ways more drastically than you might suspect. (The fact that execution time tripled when storing an ID vs. storing an Account record is still a bit perplexing.)

Tags:

Cpu

Apex

Sort