Fix benchmark

This commit is contained in:
haad 2016-11-25 15:50:42 +01:00
parent 0823b15b1c
commit c636bbfd00

View File

@ -20,29 +20,29 @@ const queryLoop = (db) => {
}
// Start
let run = (() => {
IpfsDaemon({ IpfsDataDir: '/tmp/orbit-db-benchmark' })
.then((res) => {
const orbit = new OrbitDB(res.ipfs, 'benchmark')
const db = orbit.eventlog('orbit-db.benchmark')
console.log("Starting...")
// 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`)
queriesPerSecond = 0
}, 1000)
const ipfs = new IpfsDaemon({ IpfsDataDir: '/tmp/orbit-db-benchmark' })
// Start the main loop
queryLoop(db)
})
.catch((e) => console.error(e))
})()
ipfs.on('error', (err) => console.error(err))
module.exports = run
ipfs.on('ready', () => {
const orbit = new OrbitDB(ipfs, 'benchmark')
const db = orbit.eventlog('orbit-db.benchmark')
// 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`)
queriesPerSecond = 0
}, 1000)
// Start the main loop
queryLoop(db)
})