On Wed, May 29, 2013 at 1:39 PM, Antoine Musso <[email protected]> wrote:
> Le 29/05/13 16:21, Tyler Romeo a écrit :
>> So I ran a brief benchmark on my vagrant instance recently (nothing fancy,
>> just 50,000 iterations of a single line of code), and I found that
>> htmlspecialchars() performs *significantly* faster than strtr() (a
>> difference of like 37%).
>>
>> Html::element (and other places in the Html class) prefer using strtr()
>> with a manual list of some elements rather than htmlspecialchars(). The
>> reasoning behind this (I think) is do make the output document slightly
>> smaller by a few bytes by not escaping unnecessary items.
>>
>> So my question is if the byte reduction is really worth it, or if we would
>> rather have a 37% reduction in escaping speed?
>
> I wrote a dumb benchmarking class a while ago under
> maintenance/benchmarks feel free to add one there.
>
> The original code seems to be by Aryeh in 0120d492b  and mentioned
> indeed "we" liked the size difference.
>
> I would go for speed, that might also makes the code simpler.

Perhaps. But if it's only marginally faster (like, half a ms), then the reduced
output probably saves more in the long run. But without actual numbers
we're really just guessing at possible micro-optimizations.

-Chad

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to