Fix benchmark
This commit is contained in:
parent
0823b15b1c
commit
c636bbfd00
@ -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)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user