-
Notifications
You must be signed in to change notification settings - Fork 73
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
Performance improvements #11
Conversation
- rand_in_range(0, 1) is equivalent to random.random() - random.uniform(-1, 1) performs much better than random.choice([-1, 1]) * random.random()
After random()-related changes it became a wrapper for random.uniform(-1, 1)
…stem log every time
There are usually fewer stems than leaves, so it deserves a lower refresh rate
Mostly caching variables that are used repeatedly and reducing performance penalties due to scoping
Quaking Aspen with leaves (seed 100): Before: After: Douglas Fir with leaves (seed 100): Before: After: Weeping Willow with leaves (seed 100): Before: After: Summary Stems: Leaves: Testbench specs: Acer Aspire v3-771G (laptop) |
I've figured it out; seeds are still working. By replacing I did notice a different bug while reading through the diff; got that patched up. |
mathutils.Vector is implemented in C. By extending the class in Python, a bunch of Python-related overhead is added, which damages the speed gains from the original C implementation. This change brings Quaking Aspen seed 100 from an average of 4.317s down to an average of 3.981s
This reverts commit c1c00a1.
Tried another change. Further testing showed little difference in performance, hence the revert. |
I'll try and get around to fully reviewing and testing this on the weekend as there are a lot of changes to merge without any checks! Nonetheless, very impressive work! |
This PR contains a slew of performance improvements, both small and large.
The largest improvement included is the replacement of deepcopy() with a simple list comprehension, which dramatically speeds up leaf generation.
Other changes include:
Moving stdout handling to a separate thread (the overhead for printing that frequently turned out to be bananas)
Replacing a couple of the manual implementations of random number generation with faster built-ins (I ran a bunch of rounds of timeit to make sure they were improvements).
Addition of .idea/ to the .gitignore (the folder that PyCharm uses to store its project config)
Some general format cleanup; adding whitespace between code blocks and such. Not a meticulous overhaul by any means.