Re: Support for keywords where possible
| From: | Bob Weinand | Date: | Thu, 12 Sep 2013 12:56:42 +0000 |
| Subject: | Re: Support for keywords where possible | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69094@lists.php.net to get a copy of this message | ||
Am 12.9.2013 um 09:10 schrieb Michael Wallner <mike@php.net>:
> On 11 September 2013 23:21, Bob Weinand <bobwei9@hotmail.com> wrote:
>> Hi!
>>
>> I tried to widen the naming possibilities by allowing to use keywords as identifiers (for
>> function names, class names, label (goto) names, ....) where possible. It doesn't break any BC.
>>
>> Furthermore when BC needs to be broken in future for new keywords, it will have a smaller
>> impact as most usages of the new keyword then still work.
>
> I like the idea, but it looks like the patch defers many string
> comparisons from the parser to strcmps. Do you have performance
> comparisons of running e.g. a framework, which uses those keywords a
> lot?
>
> --
> Regards,
> Mike
A little benchmark here: https://gist.github.com/bwoebi/6536824
Here I picked always the best from 10 times running.
With patch:
root# ./sapi/cli/php microbench.php
Took for 10000 iterations: 8.6687519550323 seconds
Without patch:
root# ./sapi/cli/php ../bwo-php-src/microbench.php
Took for 10000 iterations: 8.5741410255432 seconds
But this is the very worst case. (e.g. there are JUST cases where strncasecmp needs to be used)
When picking random files the results are pretty similar:
With patch:
root# ./sapi/cli/php microbench.php
Took for 10000 iterations: 15.564201116562 seconds
Without patch:
root# ./sapi/cli/php microbench.php
Took for 10000 iterations: 15.562065023422 seconds
It's here only a difference of about 2 milliseconds or 0,01% what is in the margin of error I
think.
Bob Weinand