分析Google App脚本的性能 [英] Profiling the Performance of a Google App Script

查看:97
本文介绍了分析Google App脚本的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Google App脚本,将Google Analytics(分析)数据提取到Google Spreadsheet中.这是一个运行时间较长的脚本,向GA Reporting API发出了多个请求,它还使用了Google App的ScriptDB.

I've written a Google App Script to pull in Google Analytics data into a Google Spreadsheet. It's a fairly long running script making multiple requests to the GA Reporting API, it also uses Google App's ScriptDB.

是否有一种很好的方法来分析脚本性能的每一步,所以我可以弄清楚哪些区域花费的时间最长,因此可以开始在某些区域进行优化?

Is there a good way of profiling each step of the scripts performance so I can figure out what areas are taking the longest, so I can begin optimizing in certain areas?

推荐答案

执行记录对于这种事情非常有用.

The Execution Transcript is very useful for this kind of thing.

您还可以将Logger.log()语句放置在测量自上次日志以来的时间的所有位置.这样,您可以找到执行时间更长的区域.

You can also put Logger.log() statements all over the place that measure the time since the last log. That way you can find areas that take longer to execute.

我有一个电子表格其中我在执行后复制日志,然后公式+条件格式帮助我确定速度较慢的区域.

I have a spreadsheet where I copy the log after an execution and then formulas + conditional formatting help me identify areas that are slow.

这篇关于分析Google App脚本的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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