PHP Benchmarking
July 14, 2010| Tweet |
- Efficiency
- Functionality
- Security
- Aestetics
If you're interested in downloading the code I used to benchmark these elements, there's a -zip- file for that!
They won't be exact, as I repurposed some of them (i.e. different methods to concat strings, evaluate, etc).
String Concatenation
Iterations: 500,000
Concats per iteration: 20
Probably one of the more interesting benchmarks:
$temp = $mystring . " " . $mystring . " " (...)Scored: 2.035299 Seconds
$temp = "{$mystring} {$mystring} (...)Scored: 1.237544 Seconds
$temp = "$mystring $mystring (...)Scored: 1.236022 Seconds
Other Concatenations
Iterations: 500,000
Concats per iteration: 1
Don't compare these with the previous, they're not necessarly related to them due to differing levels of concatenation.
$a = $a . $mystring;Scored: 0.584638 Seconds
$a .= $mystring;Scored: 0.575480 Seconds
String Encapsulation
Iterations: 50 Million
$a = '1234567890poiuytrewqasdfghjkl/.,mnbvcxz';Scored: 7.486550 Seconds
$a = "1234567890poiuytrewqasdfghjkl/.,mnbvcxz";Scored: 7.477590 Seconds
Conjunctive (Logical) Evaluations
Iterations: 50 Million
Performing logical evaluations on equivalent floats, that are not in variables.
Using: &&Scored: 5.898687 Seconds
Using: ANDScored: 5.799526 Seconds
Using: ||Scored: 4.663750 Seocnds
Using: ORScored: 4.600031 Seconds
Using: ===Scored: 4.065238
Using: ==Scored: 4.217280
Using: !=Scored: 3.874042
Using: !==Scored: 3.863586
Using: <Scored: 3.950963
Using: >Scored: 4.029640
Using: <=Scored: 4.288681
Using: >=Scored: 4.290717
MOAR!
There's more to come. That's all for today, kiddies. If you have any suggestions, please contact me. No comments yet! Be the first!

Facebook
LinkedIn