Last active
January 29, 2019 12:13
-
-
Save rjcorwin/9a28311bb83fa3a585e0a3830764abd9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numberOfDocs = 1000 | |
var userName = 'RJ' | |
var templateDoc = { | |
yourDocHere: true | |
} | |
var fillUp = async (numberOfDocs, templateDoc, dbName) => { | |
let initialEstimate = await navigator.storage.estimate() | |
let db = new PouchDB(dbName) | |
delete templateDoc._rev | |
let i = 0 | |
while (numberOfDocs > i) { | |
let doc = Object.assign({}, templateDoc, { _id: `${i}` }) | |
await db.put(doc) | |
i++ | |
} | |
let concludingEstimate = await navigator.storage.estimate() | |
console.log(` | |
Initial Estimate: ${JSON.stringify(initialEstimate)} | |
Concluding estimate: ${JSON.stringify(concludingEstimate)} | |
Usage Difference: ${concludingEstimate.usage - initialEstimate.usage} bytes | |
Average Doc Size: ${(concludingEstimate.usage - initialEstimate.usage) / numberOfDocs} bytes | |
`) | |
} | |
fillUp(numberOfDocs, templateDoc, userName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment