Unnest the Timer class#81
Merged
brian-brazil merged 1 commit intoprometheus:masterprometheus/client_python:masterfrom Jun 1, 2016
Merged
Unnest the Timer class#81brian-brazil merged 1 commit intoprometheus:masterprometheus/client_python:masterfrom
brian-brazil merged 1 commit intoprometheus:masterprometheus/client_python:masterfrom
Conversation
Contributor
|
There's two other Timer classes. How big is the performance difference? |
Contributor
Author
|
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 |
Contributor
|
That's a pretty nice improvement, most of the slowness is due to the mutex at that point. |
Contributor
Author
|
Indeed. Do you want me to move the other classes in this PR, or a separate one? |
Contributor
|
All in one PR please. |
Contributor
Author
|
@brian-brazil done. |
prometheus_client/core.py
Outdated
Contributor
There was a problem hiding this comment.
We can remove this blank line now.
Contributor
|
That looks generally fine, can you squash your commits please? |
Classes are relatively expensive to create, and particularly disadvantageous on PyPy.
Contributor
Author
|
@brian-brazil done! |
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
classes are relatively expensive to create, and particularly disadvantageous on PyPy
A benchmark could be created if this was useful