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

Travis CI: Identify our ten slowest pytests #2350

Merged
merged 2 commits into from Aug 25, 2020
Merged

Travis CI: Identify our ten slowest pytests #2350

merged 2 commits into from Aug 25, 2020

Conversation

@cclauss
Copy link
Member

cclauss commented Aug 25, 2020

https://howchoo.com/g/mtblodnjzjc/how-to-measure-unit-test-execution-times-in-pytest helps us to find the individual tests that are slowing down our Travis CI checks.

============================= slowest 10 durations =============================
36.16s call     project_euler/problem_34/sol1.py::problem_34.sol1.compute
20.02s call     sorts/sleep_sort.py::sleep_sort.sleep_sort
5.86s call     project_euler/problem_43/sol1.py::problem_43.sol1.compute_sum
5.82s call     graphs/bidirectional_breadth_first_search.py::bidirectional_breadth_first_search.BreadthFirstSearch
5.04s call     project_euler/problem_27/problem_27_sol1.py::problem_27_sol1.solution
4.90s call     project_euler/problem_44/sol1.py::problem_44.sol1.compute_num
4.70s call     project_euler/problem_25/sol1.py::problem_25.sol1.solution
4.03s call     project_euler/problem_33/sol1.py::problem_33.sol1.solve
3.52s call     project_euler/problem_47/sol1.py::problem_47.sol1.solution
2.86s call     maths/miller_rabin.py::maths.miller_rabin.is_prime
================ 738 passed, 769 warnings in 132.17s (0:02:12) =================

@Kush1101 Given that our slowest test is taking 36 seconds on every pull request, would you be willing to look at that test and see if you can speed things up? Also, the third test.

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
cclauss and others added 2 commits Aug 25, 2020
https://howchoo.com/g/mtblodnjzjc/how-to-measure-unit-test-execution-times-in-pytest helps us to find the individual tests that are slowing down our Travis CI checks.
@cclauss cclauss changed the title Travis CI: Identify our ten slowest tests Travis CI: Identify our ten slowest pytests Aug 25, 2020
@cclauss cclauss requested review from poyea and itsvinayak Aug 25, 2020
@Kush1101
Copy link
Contributor

Kush1101 commented Aug 25, 2020

@cclauss. Sure

@Kush1101
Copy link
Contributor

Kush1101 commented Aug 25, 2020

@cclauss. Sure

PR #2305 which added the file problem_34 (which takes the longest time) did not pass all the tests. Here is the log of the test which failed.
The solution itself takes more than 15 seconds to run, so @cclauss Do you suggest that I should come up with a more efficient solution and discard the existing one or simply resolving the failed test would speed things up?

@cclauss
Copy link
Member Author

cclauss commented Aug 25, 2020

The idea is to not lower the reader’s confidence that the code will work as expected.

Best: speed up the implementation and keep the test.
Good: find a similar test that runs faster
Acceptable: comment out the test but do not remove it and write down why you have done so.

@Kush1101
Copy link
Contributor

Kush1101 commented Aug 25, 2020

The idea is to not lower the reader’s confidence that the code will work as expected.

Best: speed up the implementation and keep the test.
Good: find a similar test that runs faster
Acceptable: comment out the test but do not remove it and write down why you have done so.

I can speed up the implementation. Shall I start a PR now?

cclauss added a commit that referenced this pull request Aug 25, 2020
A silly algorithm designed to waste time.  #2350 demonstrates that it is a 20+ second denial of service attack on every Travis CI run that we do.
@cclauss cclauss mentioned this pull request Aug 25, 2020
1 of 14 tasks complete
@cclauss
Copy link
Member Author

cclauss commented Aug 25, 2020

Please don’t wait for permission... If you see something that should be done then do it.

@poyea
poyea approved these changes Aug 25, 2020
@cclauss cclauss merged commit e776006 into master Aug 25, 2020
3 checks passed
3 checks passed
codespell
Details
Gitpod Open an online workspace in Gitpod
Details
Travis CI - Pull Request Build Passed
Details
cclauss added a commit that referenced this pull request Aug 25, 2020
* Delete sleep_sort.py

A silly algorithm designed to waste time.  #2350 demonstrates that it is a 20+ second denial of service attack on every Travis CI run that we do.

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
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

4 participants
You can’t perform that action at this time.