Skip to content
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

Add separated tests for three string formatting methods #29

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

97littleleaf11
Copy link

The three microbenchmarks share the same logic. Currently there are only limited cases, including %s, %d and %f, whose distribution is not exactly the same compared with real world situation.

I would first mark this PR as draft for further discussion.

@97littleleaf11
Copy link
Author

97littleleaf11 commented Jun 21, 2021

% operator:

interpreted: 0.401913s (avg of 5 iterations; stdev 0.54%)
compiled:    0.303943s (avg of 5 iterations; stdev 0.76%)

compiled is 1.322x faster

str.format:

running str_format_format_method
..........
interpreted: 0.581258s (avg of 5 iterations; stdev 0.28%)
compiled:    0.495334s (avg of 5 iterations; stdev 0.66%)

compiled is 1.173x faster

f-string:

running str_format_format_fstring
..........
interpreted: 0.288576s (avg of 5 iterations; stdev 0.83%)
compiled:    0.759397s (avg of 5 iterations; stdev 0.37%)

compiled is 0.380x faster

@97littleleaf11
Copy link
Author

after python/mypy#10697:

running str_format_format_method
..........
interpreted: 0.587563s (avg of 5 iterations; stdev 0.35%)
compiled:    0.282582s (avg of 5 iterations; stdev 0.32%)

compiled is 2.079x faster

@97littleleaf11
Copy link
Author

after python/mypy#10762:

running str_format_format_method
..........
interpreted: 0.574899s (avg of 5 iterations; stdev 0.25%)
compiled:    0.156026s (avg of 5 iterations; stdev 0.63%)

compiled is 3.685x faster

@97littleleaf11
Copy link
Author

after python/mypy#10776:

running str_format_fstring
..........
interpreted: 0.295028s (avg of 5 iterations; stdev 2.3%)
compiled:    0.188493s (avg of 5 iterations; stdev 1.7%)

compiled is 1.565x faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant