performance - Google apps 脚本 - 加速 getActiveDocument()?

标签 performance google-apps-script google-docs

我正在编写一个脚本,用于将 Google 文档中的选定文本设置为大写。该脚本工作正常,但在大型文档中速度非常慢。因此,我剥离了几乎所有内容来执行一些速度测试,我意识到这个简单的行:

      var document = DocumentApp.getActiveDocument();

执行 150 页文档需要 9-10 秒。

有没有办法加快这个过程,即预先缓存“文档”,以便当我调用脚本时我可以使用我的 getCursor()getSelection()在合理的时间内?

最佳答案

您无法预缓存此内容。 为缓存提供的服务有:

  • CacheService:仅存储字符串值
  • ScriptDB:无法在此存储文档。

所以我担心你需要应对它。

关于performance - Google apps 脚本 - 加速 getActiveDocument()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20121427/

相关文章:

google-apps-script - 即使页面存在,Google 脚本 UrlFetchApp.fetch 返回 404

performance - 当我已经拥有 AWS ELB 时,是否还需要拥有 HAProxy TCP/HTTP 负载均衡器?

c++ - 在 vector 的每个结构元素中重置值的最快方法?

google-apps-script - 在 Google Apps 脚本中删除用户 - 修复 "Resource Not Found userKey"错误

google-apps-script - 谷歌应用程序脚本 : How to copy text and preserve formatting?

google-sheets - 如何在 Google Sheet 上从表单收集数据的列中过滤搜索?

javascript - 比较 indexOf 的结果时的性能

javascript - 在函数内执行 addEventListener()

css - 使用 CSS 从谷歌应用脚​​本上传本地路径图像

javascript - 使用 Google 文档中的 Google Apps 脚本更改光标所在单词的颜色