Closed dHutchings closed 1 year ago
@dHutchings Thank you very much for these optimizations.
When I wrote this, my primary objective was to get something that works. I am also very much beginner at python, so I am not surprised that my code may be inefficient. Most of my prints are typically a few hours, so waiting 20-30s for it to parse is still fine, but timing out after 2 hours, that is way to long.
Hello! I have found your preprocessing script very useful for my Flashforge Creator pro (I have 3 of them).
I typically print very large files on my CreatorPro2; typically, they take 1-2 days to pint.
Recently, I got a new computer, and after setting up PrusaSlicer and your extension; the exporting process would never finish.
The code was taking hours when it used to take ~2 minutes. I eventually tracked this problem down to a combination of Python versions (3.11 vs 3.10) and inefficient calling of regex.
I would like to submit a pull request with the following changes:
These changes put together make a substantial difference in runtime. For testing, I ran this code on a large gcode file "PanTiltBotCabling.gx.gcode", under various parameters. This file is rather large (53MB).
The original code, on a chromebook running python3.8, took 34 seconds to run and called regex 21.2 Million times:
The original code, on a chromebook running python 3.11, timed out after over two hours of runtime.
The new code, on a chromebook running python 3.8, took 10.5 seconds and (only) 4.7 Million calls to regex:
The new code, on a chromebook running python 3.8, took 16 seconds and an identical number of calls to regex:
The root cause of this problem is inefficiency (many millions of calls to regex) and python 3.11 making many, many changes to regex, one of which presumably slowed this specific regex down greatly.
I have tested that this new code produces 100% identical results to the original code; at least for the prints I run.
Please consider this change! I hope this helps people out!