-
Notifications
You must be signed in to change notification settings - Fork 834
Unnest the Timer class #81
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
Conversation
|
There's two other Timer classes. How big is the performance difference? |
|
Using this simple benchmark: from prometheus_client import Histogram
def main():
h = Histogram("nonsense_latency_seconds", "Latency of nonsense (seconds)")
for i in xrange(100000):
with h.time():
pass
if __name__ == "__main__":
main()On PyPy 5.1.1 WIth patch: master: So pretty massive. This optimization should be made to all the other nested |
|
That's a pretty nice improvement, most of the slowness is due to the mutex at that point. |
|
Indeed. Do you want me to move the other classes in this PR, or a separate one? |
|
All in one PR please. |
|
@brian-brazil done. |
prometheus_client/core.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this blank line now.
|
That looks generally fine, can you squash your commits please? |
Classes are relatively expensive to create, and particularly disadvantageous on PyPy.
|
@brian-brazil done! |
|
Thanks! |
classes are relatively expensive to create, and particularly disadvantageous on PyPy
A benchmark could be created if this was useful