使用计算机时间过多的Google Apps脚本服务 [英] Google Apps Script Service Using Too Much Computer Time for One Day

查看:99
本文介绍了使用计算机时间过多的Google Apps脚本服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在昨天运行的一(1)个脚本的主题中收到了错误消息,并且我假设我今天会收到类似消息。



我已经改进了脚本(每分钟运行一次触发器),所以它的功能更多地沿着它应该如何运行,但是错误消息让我想到哪些功能或程序可能要求例如,我不得不在我的谷歌应用程序脚本中使用多个睡眠呼叫,以允许数据导入运行,并再次为工作表更改/复制粘贴调用进程。是否所有这些睡眠呼叫在服务时间方面都与我无关?

我会代表社区询问,这是一个开放性问题,并非特定于睡眠功能。

预先感谢,
Barry每次调用服务(电子表格,日历或其他)比普通的JavaScript操作花费更多的时间。
例如,如果您必须修改Spreadsheet中的10个单元格,
调用range.setValue()10次所花费的时间要比数组中的所有数据多一次,然后一次更新电子表格使用range.setValues()。

如果您可以粘贴代码片段,社区将能够提供更多关于如何改进脚本的建议。

So I got the error message in the subject on the 1 (one) script I had running yesterday and I am assuming I will get a similar message today.

I have improved the script (which has a trigger to run once per minute) so it functions more along the lines of how it is supposed to however the error message got me thinking as to what sort of functions or bits of programs might be asking for more service time than others.

For example, I have had to use multiple sleep calls in my google apps script to allow the data import to run and again for the worksheet changes/copy paste calls to process. Are all those sleep calls counting against me in terms of service time used?

I would ask on the community's behalf that this be left as an open ended question not specific to the sleep function. What sorts of parts of a script are demanding service time and which are not (if any).

Thanks in advance, Barry (a.k.a. onefineham)

解决方案

Every call to a service (Spreadsheet, Calendar or whatever) takes more time than regular JavaScript operations. For example, if you have to modify 10 cells in a Spreadsheet, calling range.setValue() 10 times takes far more time than having all the data in an array and then updating the spreadsheet in one go using range.setValues().

If you can paste pieces of your code, the community will be able to offer more advice on how to improve your script.

这篇关于使用计算机时间过多的Google Apps脚本服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆