42885b20a4
Use latest store modules from npm Update README Update docs Update examples Update benchmarks Update dependencies Add Getting Started guide Add new a screenshot Add a new live demo Add persistency tests for snapshot saving/loading and events Add network stress tests (but skip them by default as they're very heavy and lengthy) Add browser benchmarks Add log() alias for eventlog() database Add possibility to create database if it doesn't exist yet Add support for orbitdb addresses Add a test for starting replication when peers connect Add debug build Use IPFS nodeID as default user id Use ipfs-pubsub-room Handle closing of databases properly Handle cache errors Clean up tests, re-organize code files Clean up code style Support for CLI Remove obsolete scripts
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
'use strict'
|
|
|
|
const IPFS = require('ipfs')
|
|
const IPFSRepo = require('ipfs-repo')
|
|
const DatastoreLevel = require('datastore-level')
|
|
const OrbitDB = require('../src/OrbitDB')
|
|
|
|
// Metrics
|
|
let totalQueries = 0
|
|
let seconds = 0
|
|
let queriesPerSecond = 0
|
|
let lastTenSeconds = 0
|
|
|
|
// Main loop
|
|
const queryLoop = async (db) => {
|
|
await db.add(totalQueries)
|
|
totalQueries ++
|
|
lastTenSeconds ++
|
|
queriesPerSecond ++
|
|
setImmediate(() => queryLoop(db))
|
|
}
|
|
|
|
// Start
|
|
console.log("Starting IPFS daemon...")
|
|
|
|
const repoConf = {
|
|
storageBackends: {
|
|
blocks: DatastoreLevel,
|
|
},
|
|
}
|
|
|
|
const ipfs = new IPFS({
|
|
repo: new IPFSRepo('./orbitdb/benchmarks/ipfs', repoConf),
|
|
start: false,
|
|
EXPERIMENTAL: {
|
|
pubsub: false,
|
|
sharding: false,
|
|
dht: false,
|
|
},
|
|
})
|
|
|
|
ipfs.on('error', (err) => console.error(err))
|
|
|
|
ipfs.on('ready', async () => {
|
|
try {
|
|
const orbit = new OrbitDB(ipfs, './orbitdb/benchmarks')
|
|
const db = await orbit.eventlog('orbit-db.benchmark', {
|
|
replicate: false,
|
|
})
|
|
|
|
// Metrics output
|
|
setInterval(() => {
|
|
seconds ++
|
|
if(seconds % 10 === 0) {
|
|
console.log(`--> Average of ${lastTenSeconds/10} q/s in the last 10 seconds`)
|
|
if(lastTenSeconds === 0)
|
|
throw new Error("Problems!")
|
|
lastTenSeconds = 0
|
|
}
|
|
console.log(`${queriesPerSecond} queries per second, ${totalQueries} queries in ${seconds} seconds (Oplog: ${db._oplog.length})`)
|
|
queriesPerSecond = 0
|
|
}, 1000)
|
|
// Start the main loop
|
|
queryLoop(db)
|
|
} catch (e) {
|
|
console.log(e)
|
|
process.exit(1)
|
|
}
|
|
})
|