Closed icewind1991 closed 8 years ago
This patch saves 30ms walltime, what is the total parsing walltime? 300ms? Please post a profile of a single run.
Would it be possible to do the Caching in the Service
class, so all calls to it can benefit from the cache?
I'm a bit new to blackfire. Is there a way to find out which script you used to generate the profile? It if it's all good and the benefit checks out, I do agree with @staabm that I think it's a bit better to move the cache to the function in the Service class, not in the least because it also means that the cache survives multiple runs.
You can simply declare a static property inside a function body like this:
function foo() {
static $cache;
}
Never mind on sharing the original script, I seen now that it was a whole webdav request. Looking into this a bit further
Switched to using a static variable in the method.
Updated comparison: https://blackfire.io/profiles/compare/74200494-931e-436c-b367-1ec3fca31419/graph
Failing build is unrelated. Looks good!
When serializing large xml documents the cost parsing of the namespaces from clark notation becomes a significant portion (>10%) of the serialization cost. Since most xml documents will only use a fairly small number of xml elements we're better of keeping the parsed version of the namespace/element around for reuse.
This saves doing a regex (and some memory allocations) for each element we serialize
comparison
cc @evert