beaufortfrancois / omnidrive-chrome-extension

OmniDrive Chrome Extension
https://chrome.google.com/webstore/detail/gpnikbcifngfgfcgcgfahidojdpklfia
24 stars 6 forks source link

API call performance #9

Open paulirish opened 7 years ago

paulirish commented 7 years ago

Testing with my personal and corporate google accounts I have pretty decent latency on these drive requests.

I inspected the background page, and found the API request, "Copy as cURL" and am now running it with time and tweaking some parameters to see if i can get it faster.

On a simple query I am seeing minimum API call take 1.6s seconds, and maxing at 5.2s. Average/median is about 3ish seconds.

I tried a few things but they dont appear to be improving perf much

  1. migrating to drive API v3.
  2. corpus = default in api v2
  3. lastViewedByMeDate within the last three years

with all these applied it looks like:

function onInputChanged(text, suggest) {
    var url = 'https://www.googleapis.com/drive/v3/files';
    var date = new Date();
    date.setFullYear(date.getFullYear() - 3);

    var params = new URLSearchParams();
    params.append('pageSize', 5);

    var queries = [
      // text matches
      `fullText contains "${text}"`,
      // only google docs (docs, sheets, slides)
      `mimeType contains "google-apps"`,
      // viewed in last 3 years
      `lastViewedByMeDate > "${date.toISOString()}"`
    ];
    // text matches, and it's a google doc
    params.append('q', queries.join(' and '));

but like i said, the perf isn't significantly better.

The best solution is probably the same local caching approach that we ultimately did here: https://github.com/aksenol/drive-quick-search/pull/3/files

beaufortfrancois commented 7 years ago

The thing that prevented me to do the same solution as drive-quick-search is that search is less powerful. Using fullText contains is much more reliable than using a simple item.description.toLowerCase().indexOf(lowerCaseQuery)

paulirish commented 7 years ago

Yes true but it could do both... :)

On Jan 25, 2017 5:49 AM, "François Beaufort" notifications@github.com wrote:

The thing that prevented me to do the same solution as drive-quick-search is that search is less powerful. Using fullText contains is much more reliable than using a simple item.description.toLowerCase() .indexOf(lowerCaseQuery)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/beaufortfrancois/omnidrive-chrome-extension/issues/9#issuecomment-275111890, or mute the thread https://github.com/notifications/unsubscribe-auth/AACZF-4ugz1ZncA3MwyeX2gPWQ8DTty_ks5rV1LQgaJpZM4LsuTr .