Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-15 Thread Gustavo Lopes
On Mon, 14 Jan 2013 22:55:33 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: OK, so now the plan is to merge this onto 5.4: https://github.com/cataphract/php-src/compare/php:PHP-5.4...cataphract:strtr_wu94_54 And this to 5.5:

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-14 Thread Gustavo Lopes
Em 2013-01-11 0:32, Christopher Jones escreveu: How does this compare with your baseline results? I ran some benchmarks. Configure line: CC=gcc-mp-4.8 CFLAGS=-O3 -march=native ./configure --disable-all --host=x86_64-apple-darwin10 --build=x86_64-apple-darwin10 CPU: Intel(R) Core(TM)

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-14 Thread Gustavo Lopes
On Wed, 09 Jan 2013 23:45:03 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: On Thu, 03 Jan 2013 11:40:31 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: The algorithm behaves very poorly in this case because at each position of the text, all the substrings starting there and with

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-14 Thread Christopher Jones
On 01/14/2013 01:55 PM, Gustavo Lopes wrote: On Wed, 09 Jan 2013 23:45:03 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: On Thu, 03 Jan 2013 11:40:31 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: The algorithm behaves very poorly in this case because at each position of the

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-14 Thread Stas Malyshev
Hi! OK, so now the plan is to merge this onto 5.4: https://github.com/cataphract/php-src/compare/php:PHP-5.4...cataphract:strtr_wu94_54 This one looks mostly harmless, so if all strtr tests still pass I think it's OK for 5.4. -- Stanislav Malyshev, Software Architect SugarCRM:

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-10 Thread Nicolai Scheer
Hi! On 9 January 2013 23:45, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: On Thu, 03 Jan 2013 11:40:31 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: The algorithm behaves very poorly in this case because at each position of the text, all the substrings starting there and with size

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-10 Thread Christopher Jones
On 01/09/2013 02:45 PM, Gustavo Lopes wrote: On Thu, 03 Jan 2013 11:40:31 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: The algorithm behaves very poorly in this case because at each position of the text, all the substrings starting there and with size between m and n (where m is the

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-09 Thread Gustavo Lopes
On Thu, 03 Jan 2013 11:40:31 +0100, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: The algorithm behaves very poorly in this case because at each position of the text, all the substrings starting there and with size between m and n (where m is the size of the smallest pattern and n is the

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-03 Thread Gustavo Lopes
Em 2013-01-02 16:53, Nicolai Scheer escreveu: I might have chosen the wrong tool for what I'm trying to achieve in the first place, but can anyone comment on the algorithmic complexity of strtr? This is definitely not the expected behaviour for such small inputs. Since the inputs varied and

Re: [PHP-DEV] strtr vs. str_replace runtime

2013-01-03 Thread Nicolai Scheer
Hi! On 3 January 2013 11:40, Gustavo Lopes glo...@nebm.ist.utl.pt wrote: Em 2013-01-02 16:53, Nicolai Scheer escreveu: I might have chosen the wrong tool for what I'm trying to achieve in the first place, but can anyone comment on the algorithmic complexity of strtr? This is definitely

[PHP-DEV] strtr vs. str_replace runtime

2013-01-02 Thread Nicolai Scheer
Hi! I stumbled upon a problem with the function strtr() the other day... I noticed a very long running php script, and tried to reproduce the behaviour. I traced it down to a single call of strtr doing text replacements using a search = replace array. It wasn't quit obvious why the call would