svenhb / GRBL-Plotter

A GCode sender (not only for lasers or plotters) for up to two GRBL controller. SVG, DXF, HPGL import. 6 axis DRO.
https://grbl-plotter.de/
GNU General Public License v3.0
669 stars 177 forks source link

Speed up merge and sort #348

Closed heurist1 closed 1 year ago

heurist1 commented 1 year ago

This is a solution for issue #347

Surprisingly the most important change is to not access Properties.Settings.Default.importLineDashPattern thousands of times. The settings are stored in a list indexed by a string.

I have put the change into 3 separate commits that cover different aspects of the fix, so that you can decide which (if any) you want to include.

I have made the sorting work much faster by storing the index to the item with the shortest distance removing the need for a sort.

I improved the compare of properties, but the big factor here was not checking Properties.Settings.Default.importLineDashPattern more than necessary.

I have made the updating of the progress bar use less CPU. I don't think the function that decided if half a second had elapsed was working quite how you intended.

In your master branch there is currently an error that prevents it compiling. GCodeFromTeext.cs accesses Graphic.graphicInformation.OptionSortCode which doesn't exist. I deleted the line locally to perform my tests, but haven't checked in the change.

Timings before were 24min16 and are now 1min47