Hi Google Ads team,

We recently noticed a performance issue when we switch to use Google Ads 
API to download the adgroup structure report. It seems like Google Ads API 
is much slower than the Adwords API (v201809). To validate our observation, 
I have written 2 CLI programs in Java to log the time to download the 
adgroup structure data of 2 accounts with different APIs. We logged the 
time from the request being fired until we finish iterating over all the 
rows (do nothing in the loop) in the downloaded content.

The test results are as follows:

Google Adwords API

Run #1
Time to download and iterate by lines for account 5259617269 is 00:04 
(165554 rows)
Time to download and iterate by lines for account 1497931133 is 00:08 
(268578 rows)

Run #2
Time to download and iterate by lines for account 5259617269 is 00:03
Time to download and iterate by lines for account 1497931133 is 00:03

Run #3
Time to download and iterate by lines for account 5259617269 is 00:03
Time to download and iterate by lines for account 1497931133 is 00:07

---------

Google Ads API

Run #1
Time to download and iterate by lines for account 5259617269 is 01:26
Time to download and iterate by lines for account 1497931133 is 02:25

Run #2
Time to download and iterate by lines for account 5259617269 is 01:25
Time to download and iterate by lines for account 1497931133 is 02:35

Run #3
Time to download and iterate by lines for account 5259617269 is 01:27
Time to download and iterate by lines for account 1497931133 is 02:33

As you may find above, time consumed by Google Ads program was much longer 
than the program using Adwords.

Hope this issue could be brought into the team's attention. We are 
wondering if there is a better way to download reports with Google ads API 
or could you let us know if there will be any plan on improving this?

Thanks in advance!

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/cad0af13-fa21-40de-b66a-e9566783109d%40googlegroups.com.
import com.google.ads.googleads.lib.GoogleAdsClient;
import com.google.ads.googleads.v1.services.GoogleAdsRow;
import com.google.ads.googleads.v1.services.GoogleAdsServiceClient;
import com.google.ads.googleads.v1.services.SearchGoogleAdsRequest;
import com.google.auth.Credentials;
import com.google.auth.oauth2.UserCredentials;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.lang3.time.StopWatch;

public class GoogleAdsReportTimesCLI
{
    private static StopWatch m_stopWatch = new StopWatch();

    private static ImmutableList<String> m_accountsToTest = ImmutableList.of("5259617269", "1497931133");

    public static void main(String[] args)
    {
        Credentials credentials =
                UserCredentials.newBuilder()
                        .setClientId(args[0])
                        .setClientSecret(args[1])
                        .setRefreshToken(args[2])
                        .build();

        GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder()
                .setCredentials(credentials)
                .setDeveloperToken(args[3])
                .setLoginCustomerId(Long.parseLong(args[4]))
                .build();

        GoogleAdsServiceClient googleAdsServiceClient = googleAdsClient.getLatestVersion().createGoogleAdsServiceClient();

        for (String account : m_accountsToTest)
        {
            SearchGoogleAdsRequest searchGoogleAdsRequest = SearchGoogleAdsRequest.newBuilder()
                    .setCustomerId(account)
                    .setPageSize(5000)
                    .setQuery("SELECT customer.id" +
                                      "     , campaign.id " +
                                      "     , campaign.status " +
                                      "     , ad_group.id " +
                                      "     , ad_group.name " +
                                      "     , ad_group.status " +
                                      "     , ad_group.type " +
                                      "FROM ad_group")
                    .build();

            m_stopWatch.start();

            GoogleAdsServiceClient.SearchPagedResponse response = googleAdsServiceClient.search(searchGoogleAdsRequest);

            for (GoogleAdsRow row : response.iterateAll())
            {
                // no-op
            }

            System.out.println("Time to download and iterate by lines for account " + account  + " is " + DurationFormatUtils.formatDuration(m_stopWatch.getTime(), "mm:ss"));
            m_stopWatch.reset();
        }
    }
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.zip.GZIPInputStream;

import com.google.api.ads.adwords.lib.client.AdWordsSession;
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration;
import com.google.api.ads.adwords.lib.jaxb.v201809.DateRange;
import com.google.api.ads.adwords.lib.jaxb.v201809.DownloadFormat;
import com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinition;
import com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinitionDateRangeType;
import com.google.api.ads.adwords.lib.jaxb.v201809.ReportDefinitionReportType;
import com.google.api.ads.adwords.lib.jaxb.v201809.Selector;
import com.google.api.ads.adwords.lib.utils.ReportDownloadResponse;
import com.google.api.ads.adwords.lib.utils.v201809.ReportDownloader;
import com.google.api.ads.common.lib.auth.OfflineCredentials;
import com.google.api.client.auth.oauth2.Credential;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.lang3.time.StopWatch;

public class GoogleAdWordsReportTimesCLI
{
    private static StopWatch m_stopWatch = new StopWatch();

    private static ImmutableList<String> m_accountsToTest = ImmutableList.of("5259617269", "1497931133");

    public static void main(String[] args)
    {
        try
        {
            Credential credential =
                    new OfflineCredentials.Builder()
                            .forApi(OfflineCredentials.Api.ADWORDS)
                            .fromFile()
                            .build()
                            .generateCredential();

            AdWordsSession session = new AdWordsSession.Builder()
                    .fromFile()
                    .withOAuth2Credential(credential)
                    .build();

            ReportingConfiguration reportingConfiguration = new ReportingConfiguration.Builder()
                    .skipReportHeader(true)
                    .skipReportSummary(true)
                    .skipColumnHeader(true)
                    .includeZeroImpressions(true)
                    .build();
            session.setReportingConfiguration(reportingConfiguration);

            ReportDefinition definition = new ReportDefinition();
            definition.setReportType(ReportDefinitionReportType.ADGROUP_PERFORMANCE_REPORT);
            definition.setDateRangeType(ReportDefinitionDateRangeType.CUSTOM_DATE);
            definition.setDownloadFormat(DownloadFormat.GZIPPED_CSV);
            definition.setReportName(definition.getReportType().toString());

            Selector selector = new Selector();
            DateRange drResponse = new DateRange();
            Date today = new Date();
            DateFormat df = new SimpleDateFormat("yyyyMMdd");
            drResponse.setMin(df.format(today));
            drResponse.setMax(df.format(today));
            selector.setDateRange(drResponse);
            selector.getFields().addAll(
                    ImmutableList.of(
                            "ExternalCustomerId",
                            "CampaignId",
                            "CampaignStatus",
                            "AdGroupId",
                            "AdGroupName",
                            "AdGroupStatus",
                            "AdGroupType"
                    )
            );
            definition.setSelector(selector);

            for (String account : m_accountsToTest)
            {
                session.setClientCustomerId(account);

                m_stopWatch.start();

                ReportDownloadResponse response = new ReportDownloader(session).downloadReport(definition);

                try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new GZIPInputStream(response.getInputStream()))))
                {
                    String line;
                    while ((line = bufferedReader.readLine()) != null)
                    {
                        // no-op
                    }
                }
                catch (Exception e)
                {
                }

                System.out.println("Time to download and iterate by lines for account " + account  + " is " + DurationFormatUtils.formatDuration(m_stopWatch.getTime(), "mm:ss"));
                m_stopWatch.reset();
            }
        }
        catch (Exception e)
        {
            throw new RuntimeException("Errors are " + e);
        }
    }
}

Reply via email to