perf: avoid floating-point formatting in microtime - #23604
Conversation
Yes. |
TimWolla
left a comment
There was a problem hiding this comment.
I'm wondering if microtime() without true is something that actually happens in the real world, but looks correct and simple enough to me.
|
Yes, it saved half a second in phpbench. Though I guess arguable whether that's real-world usage. Stumbled upon this randomly when tracing back codegen differences between gcc tailcall (patch open) and clang tailcall. Edit: sorry, @staabm, I meant phpbench. Not phpstan. |
|
do these lines have the same problem? ext/standard/uniqid.c:72-79 also uses %.8F for a generated seed string. |
|
Yes, but I'll create a new PR since this one was already approved. |
|
to re-iterate this and hopefully I got this right:
|
Convert to long instead of double and save the division. Extra gain because
zend_strpprintf()takes the cheaper integer formatting path instead of having to callzend_dtoa().This isn't a bug fix so I guess it should target master? @devnexen