Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark slowEqual #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
and,
or,
equal,
slowEqual,
count,
toCallback,
toPullStream,
Expand Down Expand Up @@ -169,6 +170,110 @@ test('core indexes', (t) => {
)
})

const slowEqualHugeIndexQuery = (cb) => {
query(
fromDB(db),
where(slowEqual('value.content.type', 'post')),
toCallback((err, msgs) => {
if (err) {
cb(err)
} else if (msgs.length !== 23310) {
cb(new Error('msgs.length is wrong: ' + msgs.length))
}
cb()
})
)
}

test('slowEqual one huge index (first run)', (t) => {
runBenchmark(
'Query 1 big index with slowEqual (1st run)',
slowEqualHugeIndexQuery,
(cb) => {
closeLog((err) => {
if (err) cb(err)
else getJitdbReady(cb)
})
},
(err, result) => {
if (err) {
t.fail(err)
} else {
fs.appendFileSync(reportPath, result)
t.pass(result)
}
t.end()
}
)
})

test('slowEqual one huge index (second run)', (t) => {
runBenchmark(
'Query 1 big index with slowEqual (2nd run)',
slowEqualHugeIndexQuery,
(cb) => {
closeLog((err) => {
if (err) cb(err)
else getJitdbReady((err2) => {
if (err2) cb(err2)
else slowEqualHugeIndexQuery(cb)
})
})
},
(err, result) => {
if (err) {
t.fail(err)
} else {
fs.appendFileSync(reportPath, result)
t.pass(result)
}
t.end()
}
)
})

test('slowEqual count one huge index (third run)', (t) => {
runBenchmark(
'Query 1 big index with slowEqual (3rd run)',
(cb) => {
query(
fromDB(db),
where(slowEqual('value.content.type', 'post')),
count(),
toCallback((err, total) => {
if (err) {
cb(err)
} else if (total !== 23310) {
cb(new Error('total is wrong: ' + total))
}
cb()
})
)
},
(cb) => {
closeLog((err) => {
if (err) cb(err)
else getJitdbReady((err2) => {
if (err2) cb(err2)
else slowEqualHugeIndexQuery((err3) => {
if (err3) cb(err3)
else slowEqualHugeIndexQuery(cb)
})
})
})
},
(err, result) => {
if (err) {
t.fail(err)
} else {
fs.appendFileSync(reportPath, result)
t.pass(result)
}
t.end()
}
)
})

const runHugeIndexQuery = (cb) => {
query(
fromDB(db),
Expand Down