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

Chapter 3 code runs slow for me #7

Open
marc9323 opened this issue Oct 15, 2019 · 2 comments
Open

Chapter 3 code runs slow for me #7

marc9323 opened this issue Oct 15, 2019 · 2 comments

Comments

@marc9323
Copy link

marc9323 commented Oct 15, 2019

Hi,
I'm really enjoying your book! I've learned a lot in just the first three chapters.

I've run into an issue however running the chapter 3 code from the book. ( sorted number list ) The benchmark test sorts 40 numbers. I'm running exactly the same code (copied from github) and it takes 63 seconds to complete. Something has to be wrong here. I'm on a Dell Laptop (Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1992 Mhz, 4 Core(s), 8 Logical Processor(s)).

I'm running the same code that in the book it says on page 44: "1-2 seconds to run on average". I know processors vary but this seems extreme.

Is this normal behavior? I'm new to python and benchmarking so would appreciate any clarification.
Thanks,
Marc

@handcraftsman
Copy link
Owner

Marc,

The benchmark test doesn't take 1-2 seconds to run, it runs something 100 times and prints the average run time and standard deviation. In this case it times running a sort round that takes 1-2 seconds to run on average. Using Python 3.5, my box sorts 40 numbers in 1.27 seconds on average. That means when I run the benchmark test it takes about 127 seconds to run. Combined, your CPU and Python version run the same test twice as fast. That's why how many numbers you choose to sort is processor dependent. The benchmark test is useful for tracking whether a change to the engine has negatively impacted the speed of the engine. I also find it useful for detecting performance problems in the algorithm code.

Clinton

@marc9323
Copy link
Author

marc9323 commented Oct 15, 2019 via email

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

No branches or pull requests

2 participants