Giter Site home page Giter Site logo

TMDb API caching about trakttvstats HOT 3 OPEN

nliautaud avatar nliautaud commented on May 28, 2024
TMDb API caching

from trakttvstats.

Comments (3)

gervasiocaj avatar gervasiocaj commented on May 28, 2024 1

I wrote some performance tests, available at https://gist.github.com/gervasiocaj/b8c326f01cbcddad2a9f9cc8b080c823.

The sample data is structured in the following format: http://www.filltext.com/?rows=2&id={string|8}&username={username}&password={string|5}&text={lorem|30}&pretty=true

// myData format:
// [{ "id": "04Kwnn2Q", "username": "DChandrasekahran", ... }]

// myDataAsObject format:
// { "04Kwnn2Q": { "username": "DChandrasekahran", ... } }

// myDataIds format:
// [ "04Kwnn2Q" ]

The code run was the following:

const storageGet = data => new Promise(resolve => chrome.storage.local.get(data, resolve))
const storageSet = data => new Promise(resolve => chrome.storage.local.set(data, resolve))

console.time('storageSet test all data')
await storageSet({ data: myData })
console.timeEnd('storageSet test all data')

console.time('storageGet test all data')
await storageGet('data')
console.timeEnd('storageGet test all data')

// -----------------------------------------

console.time('storageSet test each data')
await storageSet(myDataAsObject)
console.timeEnd('storageSet test each data')

console.time('storageGet test each data')
await storageGet(myDataIds)
console.timeEnd('storageGet test each data')

The dataset length for the following results is 1000.

storageSet test all data: 70.7080078125ms
storageGet test all data: 28.281005859375ms
storageSet test each data: 62.2861328125ms
storageGet test each data: 24.7099609375ms

I am open to suggestions for broader tests, if needed.

from trakttvstats.

nliautaud avatar nliautaud commented on May 28, 2024

2017-10-02 18_26_13-extensions

2017-10-02 18_28_51-petzeroun s tv show and movie watched history - trakt tv

Can't find performance tests about chrome.storage.local.get, so tests may be needed to determine the best method between those two possibilities :

  • Store every cached responses in one large object and retrieve everything once (current)
  • Store each cached json response separately and retrieve those needed with individual chrome.storage.local.get calls.

from trakttvstats.

nliautaud avatar nliautaud commented on May 28, 2024

Amazing !

So there is a measurable performance hit, but very small, between getting everything and picking some. If timings increase is moderate with a huge cache object (10.000, 100.000 ?), it would confirm that it's largely preferable to load everything once.

What was the ids count of myDataIds ?

from trakttvstats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.