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

Speed up dijkstra_bankers_algorithm.py #10861

Merged
merged 4 commits into from
Oct 26, 2023

Conversation

tianyizheng02
Copy link
Contributor

Describe your change:

Contributes to #9718

Speeds up other/dijkstra_bankers_algorithm.py... apparently there was a time.sleep(1) call in the code for some reason. Also shortened the name of the file from dijkstra_bankers_algorithm.py to just bankers_algorithm.py (the referenced sources and the file documentation all refer to the algorithm as just the "banker's algorithm").

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • 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 include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@tianyizheng02
Copy link
Contributor Author

... and the file's no longer on the list. I can't believe the only reason why it was so slow was because there was a sleep call in the code 💀

============================= slowest 10 durations =============================
16.78s call     neural_network/simple_neural_network.py::neural_network.simple_neural_network.forward_propagation
0.85s call     web_programming/get_imdbtop.py::web_programming.get_imdbtop.get_imdb_top_movies
0.85s call     web_programming/fetch_anime_and_play.py::web_programming.fetch_anime_and_play.get_anime_episode
0.81s call     dynamic_programming/integer_partition.py::dynamic_programming.integer_partition.partition
0.76s call     graphs/bidirectional_a_star.py::graphs.bidirectional_a_star.AStar
0.55s call     web_programming/fetch_anime_and_play.py::web_programming.fetch_anime_and_play.search_anime_episode_list
0.44s call     matrix/count_negative_numbers_in_sorted_matrix.py::matrix.count_negative_numbers_in_sorted_matrix.generate_large_matrix
0.42s call     web_programming/fetch_anime_and_play.py::web_programming.fetch_anime_and_play.search_scraper
0.37s call     matrix/count_negative_numbers_in_sorted_matrix.py::matrix.count_negative_numbers_in_sorted_matrix.count_negatives_brute_force
0.25s call     machine_learning/mfcc.py::machine_learning.mfcc.mfcc
================== 1717 passed, 1 warning in 83.97s (0:01:23) ==================

@tianyizheng02 tianyizheng02 marked this pull request as ready for review October 23, 2023 22:57
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 23, 2023
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it

@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 26, 2023
@cclauss cclauss merged commit 5792503 into TheAlgorithms:master Oct 26, 2023
3 checks passed
@tianyizheng02 tianyizheng02 deleted the dijkstra-bankers branch October 26, 2023 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants