Repository navigation
Conversation
|
I measured this merged onto master 5ddcc35 on a Ryzen 9 5950X. GCC 15 and clang 21, flags of the official Docker image. Output matches master on 42k calls around "now" on GCC, clang and ASan. The ext/date tests give the same result as on master. Default zone UTC, negative = fewer cycles (faster):
~ is within the noise of master against master. layout? means the cycles changed and the instructions didn't. With America/New_York as the default zone it's 21–26% for the calls without an argument. Other strings run the same instructions as master. The title says |
Follow-up to b4e9b18,
php_date_initialize()already has a shortcut for"now": it builds the current time directly and returns. But it only takes that shortcut aftertimelib_strtotime()has already parsed the string, and the parsed result is thrown away. Sonew DateTime(),new DateTimeImmutable(),date_create()anddate_create_immutable(), with no argument or with"now", spend time scanning a string and allocating atimelib_timethat nobody uses.This change checks for
"now"before parsing and skipstimelib_strtotime()in that case. Everything else is unchanged.Benchmark
Release build, ns per call:
new DateTime()date_create()