Welcome Guest, Not a member yet? Register   Sign In
Things that affect our applications' performance
#10

[eluser]Derek Jones[/eluser]
Quote:After that, I tested with a smaller string (186 KB) and I got a solution more like I expected, and with a more usual PHP string (like 100 chars or less) the results were exactly as I expected.

This exemplifies why some of these benchmarkings have to be taken with a rather large grain of salt, and that recommendations for coding practices (whether written by us for our developers or for general consumption) the context is just as important as the code used.

You're using the phrase "a more usual PHP string (like 100 chars or less) as if that's indicative of what all code will be operated on, and the results of those tests cannot be extrapolated linearly across all sizes of data (both string length and size of the $items array). Especially with the context of the EE 3rd party dev guidelines, the strings in question are template tagdata - for the CI analogy, think view files. Also, the find/replace items in these situations are more than replacing 'a' with 'b', but with replacing {some_variable} with who knows how much data.

In these situations, here is an example of results of a similar testing using data that EE developers commonly encounter:

Code:
$items['foo'] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
$items['bar'] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
$items['bat'] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
        
$haz = "Lorem ipsum {foo} dolor sit amet, consectetur {bar} adipisicing {bat} elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
$doesnt_haz = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

Code:
Haz Strpos          0.2244
Haz Replace          0.1956
Haz Array Replace      0.7037

Doesnt Haz Strpos              0.0732
Doesnt Haz Replace          0.1379
Doesnt Haz Array Replace      0.3327

So I stand by our recommendations made in the EE dev guidelines.


Messages In This Thread
Things that affect our applications' performance - by El Forum - 06-29-2008, 05:57 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 07:51 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 09:07 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 09:21 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 09:42 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 11:42 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 11:56 AM
Things that affect our applications' performance - by El Forum - 06-29-2008, 01:38 PM
Things that affect our applications' performance - by El Forum - 06-29-2008, 03:40 PM
Things that affect our applications' performance - by El Forum - 06-29-2008, 03:46 PM
Things that affect our applications' performance - by El Forum - 06-29-2008, 05:11 PM
Things that affect our applications' performance - by El Forum - 06-29-2008, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB