-
Notifications
You must be signed in to change notification settings - Fork 25
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 random.seed call before every random usage #81
Merged
Conversation
This file contains 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
Make sure to regenerate the seed every time before calling a random function. This will make sure to generate different values even when running on a multi-process testing environment like py.test using the pytest-xdist plugin.
Check the captured stdout for the generated value. The result below was run against the following test file: import unittest
from fauxfactory import gen_alphanumeric
class TestCase(unittest.TestCase):
def test_1(self):
print(gen_alphanumeric())
self.fail()
def test_2(self):
print(gen_alphanumeric())
self.fail() Without the changes running on a single process mode:
Without the changes running on a multi-process mode:
After the changes running on multi-process mode:
|
APT |
Also remove pylint check from travis since there is an issue with Python 2.6.
omaciel
added a commit
that referenced
this pull request
Jan 12, 2016
Add random.seed call before every random usage
JacobCallahan
added a commit
to JacobCallahan/fauxfactory
that referenced
this pull request
Aug 27, 2022
I changed the random selection of some methods from comprehensions to uses of random.choices. Most improved by around 15%. However, gen_cjk saw a 5.5x speedup! I then took it a bit further by moving random.seed out of each method call and into the module scope. This greatly improved the runtime of each changed method. Additionally, it should still alleviate the original concern solved with omaciel#81
JacobCallahan
added a commit
to JacobCallahan/fauxfactory
that referenced
this pull request
Aug 27, 2022
I changed the random selection of some methods from comprehensions to uses of random.choices. Most improved by around 15%. However, gen_cjk saw a 5.5x speedup! I then took it a bit further by moving random.seed out of each method call and into the module scope. This greatly improved the runtime of each changed method. Additionally, it should still alleviate the original concern solved with omaciel#81
omaciel
pushed a commit
that referenced
this pull request
Aug 29, 2022
I changed the random selection of some methods from comprehensions to uses of random.choices. Most improved by around 15%. However, gen_cjk saw a 5.5x speedup! I then took it a bit further by moving random.seed out of each method call and into the module scope. This greatly improved the runtime of each changed method. Additionally, it should still alleviate the original concern solved with #81
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.
Make sure to regenerate the seed every time before calling a random
function. This will make sure to generate different values even when
running on a multi-process testing environment like py.test using the
pytest-xdist plugin.