In some of my recent code I've been using the trinary operator a lot. I suspect it may be slightly faster since it doesn't involve opening code blocks and is an operator instead of a keyword (this may be a load of bulshit, mind you)...
So....I figure I'll benchmark it. Great...I can't seem to devise good test cases.
This brings me to call upon the wisdom of my fellow Monks. First off, can somebody help me figure out some good test cases. Maybe even give me some generic guidelines for creating test cases to use with Benchmark.pm. And....if anybody happens to know off the top of their head the speed differences between the two, that'd be helpful too. ::smile::
I understand that the trinary obfuscates the code a degree...but if it gains a speed boost, I can comment it to hell and back. The thought just occured to me...does the optimizer change an If'n'Else into a trinary anyway?
In reply to Trinary or If'n'Else? by SamQi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |