Hello internals!
I have noted some strange points about str_repeat
performance. It looks
like the lesser $times
argument is, the bigger is execution time (only if
we consider big numbers).
For example, str_repeat('%d ', 12500);
is a lot slower than
str_repeat('%d ', 1250000)
.
First case (slow one):
https://3v4l.org/ZAoGi
Second case (fast one):
https://3v4l.org/YIdQM
Best regards,
Yevhen
I have noted some strange points about
str_repeat
performance. It looks
like the lesser$times
argument is, the bigger is execution time (only if
we consider big numbers).For example,
str_repeat('%d ', 12500);
is a lot slower than
str_repeat('%d ', 1250000)
.First case (slow one):
https://3v4l.org/ZAoGiSecond case (fast one):
https://3v4l.org/YIdQM
It seems you have misinterpreted the results. 4.792213439941406E-5 is
certainly much smaller than 0.013129949569702148, for instance.
--
Christoph M. Becker
Oh, yes. Sorry for that.
Thanks for pointing out.
On Sat, Sep 10, 2022 at 3:23 PM Christoph M. Becker cmbecker69@gmx.de
wrote:
I have noted some strange points about
str_repeat
performance. It looks
like the lesser$times
argument is, the bigger is execution time (only
if
we consider big numbers).For example,
str_repeat('%d ', 12500);
is a lot slower than
str_repeat('%d ', 1250000)
.First case (slow one):
https://3v4l.org/ZAoGiSecond case (fast one):
https://3v4l.org/YIdQMIt seems you have misinterpreted the results. 4.792213439941406E-5 is
certainly much smaller than 0.013129949569702148, for instance.--
Christoph M. Becker
maybe you'll find
$t=microtime(true) - $startTime;
var_dump($t,number_format($t,10));
interesting, https://3v4l.org/Ejia3
Oh, yes. Sorry for that.
Thanks for pointing out.
On Sat, Sep 10, 2022 at 3:23 PM Christoph M. Becker cmbecker69@gmx.de
wrote:I have noted some strange points about
str_repeat
performance. It
looks
like the lesser$times
argument is, the bigger is execution time
(only
if
we consider big numbers).For example,
str_repeat('%d ', 12500);
is a lot slower than
str_repeat('%d ', 1250000)
.First case (slow one):
https://3v4l.org/ZAoGiSecond case (fast one):
https://3v4l.org/YIdQMIt seems you have misinterpreted the results. 4.792213439941406E-5 is
certainly much smaller than 0.013129949569702148, for instance.--
Christoph M. Becker