Profiling the Performance of a Google App Script

google-analytics, google-analytics-api, google-apps-script, google-sheets, profiling

Solution

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

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.

Problem

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?

Original source