-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easily time functions with a closure. #43
Comments
Another nice pattern is
and then the destructor of |
To delegate the destructor the job of actually sending the timing results bugs me a little. Mainly for two reasons:
However I can see your point here. We could imagine for example enclosing foo() execution in the code of the issue proposal: $statsd->time('api.dbcall', function () use (&$fooReturn) {
$fooReturn = foo(); // your foo function
}); An idea to dig into. |
It is a hack, but a very convenient one. E.g.
This kind of sucks. It is a lot nicer to say (although admittedly harder to understand at first glance):
MediaWiki uses this pattern quite a bit (e.g. |
An idea I find interesting, found on https://github.com/thephpleague/statsd:
Would be nice to implement here :)
The text was updated successfully, but these errors were encountered: