Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
perf(pubsub): Change pubsub tests to do lighter load testing
Browse files Browse the repository at this point in the history
In reality, benchmarks should be separated completely from the normal
test suite

License: MIT
Signed-off-by: Victor Bjelkholm <git@victor.earth>
  • Loading branch information
victorb authored and daviddias committed May 6, 2018
1 parent 63179b9 commit 90a1520
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions js/src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,19 @@ module.exports = (common) => {
})
})

describe('load tests', function () {
describe('light-load tests', function () {
before(() => {
ipfs1.pubsub.setMaxListeners(10 * 1000)
ipfs2.pubsub.setMaxListeners(10 * 1000)
ipfs1.pubsub.setMaxListeners(10 * 10)
ipfs2.pubsub.setMaxListeners(10 * 10)
})

after(() => {
ipfs1.pubsub.setMaxListeners(10)
ipfs2.pubsub.setMaxListeners(10)
})

it('call publish 1k times', (done) => {
const count = 1000
it('call publish 10 times', (done) => {
const count = 10
let sendCount = 0
const topic = getTopic()

Expand Down Expand Up @@ -597,11 +597,11 @@ module.exports = (common) => {
ipfs2.pubsub.unsubscribe(topic, sub2)
})

it('send/receive 10k messages', function (done) {
it('send/receive 100 messages', function (done) {
this.timeout(2 * 60 * 1000)

const msgBase = 'msg - '
const count = 10000
const count = 100
let sendCount = 0
let receivedCount = 0
let startTime
Expand All @@ -621,7 +621,7 @@ module.exports = (common) => {
const duration = new Date().getTime() - startTime
const opsPerSec = Math.floor(count / (duration / 1000))

console.log(`Send/Receive 10k messages took: ${duration} ms, ${opsPerSec} ops / s\n`)
console.log(`Send/Receive 100 messages took: ${duration} ms, ${opsPerSec} ops / s\n`)

check()
}
Expand Down Expand Up @@ -656,8 +656,8 @@ module.exports = (common) => {
})
})

it('call subscribe/unsubscribe 1k times', (done) => {
const count = 1000
it('call subscribe/unsubscribe 10 times', (done) => {
const count = 10
let sendCount = 0
const handlers = []

Expand Down

0 comments on commit 90a1520

Please sign in to comment.