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

Improvements and simplification in corpus' handling randomisation code #22

Closed
wants to merge 1 commit into from

Conversation

@jvoisin
Copy link
Contributor

jvoisin commented Dec 31, 2019

  • Remove useless casts to bool
  • Use something faster than random.randint: this cuts in half the time spent
    in the random.py file, without raising anything else
  • use random.choice where possible, instead of mylist[_rand(len(mylist))]
  • Add some comments explaining the if…if…else structure, to prevent
    future refactoring from transforming them into an if…elif…else

On a local fuzzer, with 10000 iterations, this decrease the amount of time
spent in corpus' mutate function from ~0.2 seconds to ~0.1 seconds, for a total
run time of ~9 seconds, which seems to not be a lot, but since 8.60s is spent
in connection.py's poll function waiting for the fuzzer, it's a worthy
optimization.

- Remove useless casts to bool
- Use something faster than random.randint: this cuts in half the time spent
  in the random.py file, without raising anything else
- use random.choice where possible, instead of `mylist[_rand(len(mylist))]`
- Add some comments explaining the if…if…else structure, to prevent
  future refactoring from transforming them into an if…elif…else

On a local fuzzer, with 10000 iterations, this decrease the amount of time
spent in corpus' mutate function from ~0.2 seconds to ~0.1 seconds, for a total
run time of ~9 seconds, which seems to not be a lot, but since 8.60s is spent
in connection.py's poll function waiting for the fuzzer, it's a worthy
optimization.
@jvoisin jvoisin closed this Feb 12, 2020
@jvoisin jvoisin deleted the jvoisin:improve_random branch Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.