Answer the question
In order to leave comments, you need to log in
When should you create functions?
Hello.
I noticed that when creating functions for better reading of the code of the main program, the execution time noticeably increases when the function is called and entered.
At first, I tried to reduce the number of lines of code by creating functions that could reduce the number of lines of code. For better code readability. But I realized that this leads to an increase in the execution time of the program.
So the question is when should functions be created? Did I correctly draw conclusions regarding the increase in program execution time due to functions? Please help.
Answer the question
In order to leave comments, you need to log in
An example of a noticeable number of functions https://github.com/contributorpw/lodashgs/blob/mas... The script running time grows minimally. Many use. It's not about the size. Moreover, the scripts are well compressed before execution. And this file https://github.com/contributorpw/alasqlgs/blob/mas... (do not open on a slow network) works fine even as a user-defined function, and there, for a second, only half a minute of execution time.
You gave an example SpreadsheetApp.flush()
. This method stops all calculations and recalculates everything you have in the Table. It's probably why you're having problems.
Based on your previous questions, you enhance the work of the interface, put pressure on the impression. Well, in the browser it will work as it will, and it will not work to make it all work faster.
Advice. Give up
Everything stands out at once. Now you can see what range I'm working with. It is much clearer what falls within the range values.
Well, without code, it makes no sense to talk about any kind of optimization.
The general principles are, try to access documents and the disk less often if you do.
If you are working with a spreadsheet, try to redraw the interface less frequently (spreadsheet.flush()).
Again, you need your code to understand what you are doing.
---
Maxim Stoyanov (stomaks), developer of Google Apps Script .
g-apps-script.com
stomaks.me
execution time noticeably increases when a function is called and entered into it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question