SamQi has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trinary or If'n'Else?
by chromatic (Archbishop) on Dec 22, 2000 at 06:11 UTC | |
|
Re: Trinary or If'n'Else?
by Maclir (Curate) on Dec 22, 2000 at 06:41 UTC | |
|
Re: Trinary or If'n'Else?
by Fastolfe (Vicar) on Dec 22, 2000 at 08:26 UTC | |
|
Re: Trinary or If'n'Else?
by Anonymous Monk on Dec 22, 2000 at 08:46 UTC | |
by Maclir (Curate) on Dec 22, 2000 at 08:52 UTC | |
by Anonymous Monk on Dec 22, 2000 at 09:09 UTC | |
by tye (Sage) on Dec 22, 2000 at 09:32 UTC | |
by I0 (Priest) on Dec 24, 2000 at 03:20 UTC | |
|
Re: Trinary or If'n'Else?
by nop (Hermit) on Dec 22, 2000 at 18:49 UTC | |
|
Re: Trinary or If'n'Else?
by SamQi (Beadle) on Dec 24, 2000 at 00:23 UTC |