Is there any way to speed up macro execution?

Here is where you can request new features or special features.

Re: Is there any way to speed up macro execution?

Postby Robertspark » Sat Nov 26, 2016 8:24 am

2nd approach,

Why not use /n for newline, and include the newline within the string that you are joining....

You've not included the newline within the concatenate string and that is probably why it's out of sequence

Note... I've not tried the above before... But interested in the approach
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there any way to speed up macro execution?

Postby ger21 » Sat Nov 26, 2016 1:31 pm

Robertspark wrote:
Why not use /n for newline,


Google led me to some info that says Environment.NewLine is actually preferred over \n?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Is there any way to speed up macro execution?

Postby Robertspark » Sat Nov 26, 2016 1:44 pm

Hmm... Ok, but not convinced....

.... I'd add /n to the string so it reads
gcode = gcode + "g01 x100 y100" + /n;
... Give it a go and retest.... Think the brackets 2nd set may be creating a problem with out of sequence running
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there any way to speed up macro execution?

Postby Robertspark » Sat Nov 26, 2016 2:26 pm

oops.... got that one wrong....
https://www.dotnetperls.com/newline

try 2nd option with the below and see if it will now run in sequence
string Gcode =" ";
Gcode = Gcode + "G1 X1 F30 /r/n";
Gcode = Gcode + "G1 X2 /r/n";
Gcode = Gcode + "G1 X3 /r/n";
Gcode = Gcode + "G1 X4 /r/n";
Gcode = Gcode + "G1 X5 /r/n";
Gcode = Gcode + "M968 P2 Q14 /r/n";
Gcode = Gcode + "M969 P2 Q14 /r/n";
Gcode = Gcode + "G1 X6 /r/n";
Gcode = Gcode + "G1 X7 /r/n";
Gcode = Gcode + "G1 X8 /r/n";
Gcode = Gcode + "G1 X9 /r/n";
Gcode = Gcode + "G1 X10 /r/n";
Gcode = Gcode + "G0 X0 /r/n";
exec.Code("" + Gcode);
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there any way to speed up macro execution?

Postby Robertspark » Sat Nov 26, 2016 2:31 pm

Think you can also do this too (tidy up the code a bit?):

string Gcode =" ";
Gcode += "G1 X1 F30 /r/n";
Gcode += "G1 X2 /r/n";
Gcode += "G1 X3 /r/n";
Gcode += "G1 X4 /r/n";
Gcode += "G1 X5 /r/n";
Gcode += "M968 P2 Q14 /r/n";
Gcode += "M969 P2 Q14 /r/n";
Gcode += "G1 X6 /r/n";
Gcode += "G1 X7 /r/n";
Gcode += "G1 X8 /r/n";
Gcode += "G1 X9 /r/n";
Gcode += "G1 X10 /r/n";
Gcode += "G0 X0 /r/n";
exec.Code("" + Gcode);

https://www.tutorialspoint.com/csharp/c ... rators.htm
assignment operator
+= Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand C += A is equivalent to C = C + A
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there any way to speed up macro execution?

Postby Robertspark » Sat Nov 26, 2016 3:58 pm

Thanks Terry, learnt something else (didn't have a clue how you were timing the macro).
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there any way to speed up macro execution?

Postby cncdrive » Sun Nov 27, 2016 5:11 pm

ger21 wrote:I'm using some macros to control some screen elements. When I click the buttons, there's a delay, and it takes about 1 second before I can press it again. Hotkeys assigned to the buttons do the same thing.
This makes the screen response feel a bit sluggish.

For example, on the jog screen, I have a + and - button that changes the jog percent or step increment, depending on which is active. I basically use the same code in a Mach3 screen, and the macro executes as fast as I can press the keys. But in UCCNC, I can only press the key about 1 time/second. So, If I want to cycle through 5 steps, it takes nearly 5 seconds, where in Mach3 I could do it in about 1 second, with 5 quick taps on the keys.

My custom checkboxes (Toggle buttons that activate hidden checkboxes) also act similarly, taking nearly a second to change state.

Is this because the macros are compiled as needed?


In the new test release version 1.2030 : viewtopic.php?f=2&t=240&start=20
We've changed the macros compiling method, now once the macro is compiled the assembly is stored in memory and on the next run of the same macro the assembly is executed without a new compilation of the macro text. The macro compiler always checks if the macro text was changed or not and if it was changed then it recompiles the macro and if it was not then it runs the precompiled assembly.
Running the precompiled assembly without a new compilation runs the macro about 1000 times faster, 50millisec vs. 50microsec on my PC.
I've also made an option (General settings page) to precompile the all macros on the software startup.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Is there any way to speed up macro execution?

Postby ger21 » Sun Nov 27, 2016 5:38 pm

Thank you, it now works much better, even without using the pre-compiling option.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Is there any way to speed up macro execution?

Postby cncdrive » Sun Nov 27, 2016 6:17 pm

Gerry, yes, even without precompiling them will be fast after the first run of the macro, because we've changed the whole macro compiling method,
so if the precompile on startup option is not set then the first macro run will compile the macro and will store the assembly, so on the second, third etc. runs of the macro it will be fast,
except if you change the macro text, if you change that then the first run again will be a compilation, but then again the macro assembly will be stored, so the next runs will be again fast and so on...
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Is there any way to speed up macro execution?

Postby Robertspark » Mon Dec 05, 2016 6:27 pm

TP,

Do you know if its the "#xx" that is the problem, or the equals in "#xx = #xx" that is the problem?
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

PreviousNext

Return to Feature Request

Who is online

Users browsing this forum: No registered users and 1 guest