Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit 573aeaf

Browse files
committed
Utilizing orbit-db-benchmark-runner
moving benchmarks to legacy folder removing runner folder npm install orbit-db-benchmark-runner new benchmarks adding benchmark to CI adding nyc to benchmark running Making the benchmarks more CI-friendly
1 parent f994a11 commit 573aeaf

29 files changed

Lines changed: 134 additions & 401 deletions

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
- run: npm run lint
7676
- run: npm test
7777
- run: npm run test:browser
78+
- run: npm run benchmark
7879
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
7980
# Save test results
8081
- store_test_results:
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
33

44
const base = {
55
prepare: async function () {
6-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/ipfs')
7-
const { log } = await createLog(ipfs, 'A')
8-
return { log, ipfs, repo }
6+
const ipfsd = await startIpfs('js-ipfs', config)
7+
const { log } = await createLog(ipfsd.api, 'A')
8+
return { log, ipfsd }
99
},
1010
cycle: async function ({ log }) {
1111
await log.append('Hello', 32)
1212
},
13-
teardown: async function ({ repo }) {
14-
await repo.close()
13+
teardown: async function ({ ipfsd }) {
14+
await stopIpfs(ipfsd)
1515
}
1616
}
1717

benchmarks/runner/benchmarks/find-heads.js renamed to benchmarks/find-heads.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
3-
const Log = require('../../../src/log')
3+
const Log = require('../src/log')
44

55
const base = {
66
prepare: async function () {
7-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/ipfs')
8-
const { log } = await createLog(ipfs, 'A')
7+
const ipfsd = await startIpfs('js-ipfs', config)
8+
const { log } = await createLog(ipfsd.api, 'A')
99

1010
process.stdout.clearLine()
1111
const entries = []
@@ -15,13 +15,13 @@ const base = {
1515
entries.push(entry)
1616
}
1717

18-
return { log, repo, entries }
18+
return { log, entries, ipfsd }
1919
},
2020
cycle: async function ({ log, entries }) {
2121
return Log.findHeads(entries)
2222
},
23-
teardown: async function ({ repo }) {
24-
await repo.close()
23+
teardown: async function ({ ipfsd }) {
24+
await stopIpfs(ipfsd)
2525
}
2626
}
2727

@@ -37,7 +37,7 @@ const stress = {
3737
}
3838
}
3939

40-
const counts = [1, 100, 1000, 10000]
40+
const counts = [1, 100, 1000]
4141
const benchmarks = []
4242
for (const count of counts) {
4343
const c = { count }

benchmarks/runner/benchmarks/from-entry-hash.js renamed to benchmarks/from-entry-hash.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
3-
const Log = require('../../../src/log')
3+
const Log = require('../src/log')
44

55
const base = {
66
prepare: async function () {
7-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/fromEntryHash/ipfs')
8-
9-
const { log, access, identity } = await createLog(ipfs, 'A')
7+
const ipfsd = await startIpfs('js-ipfs', config)
8+
const { log, access, identity } = await createLog(ipfsd.api, 'A')
109
const refCount = 64
1110
process.stdout.clearLine()
1211
for (let i = 1; i < this.count + 1; i++) {
1312
process.stdout.write(`\r${this.name} / Preparing / Writing: ${i}/${this.count}`)
1413
await log.append('hello' + i, refCount)
1514
}
16-
return { ipfs, repo, log, access, identity }
15+
return { ipfsd, log, access, identity }
1716
},
18-
cycle: async function ({ log, ipfs, access, identity }) {
19-
await Log.fromEntryHash(ipfs, identity, log.heads.map(e => e.hash), {
17+
cycle: async function ({ log, ipfsd, access, identity }) {
18+
await Log.fromEntryHash(ipfsd.api, identity, log.heads.map(e => e.hash), {
2019
access,
2120
logId: log._id
2221
})
2322
},
24-
teardown: async function ({ repo }) {
25-
await repo.close()
23+
teardown: async function ({ ipfsd }) {
24+
await stopIpfs(ipfsd)
2625
}
2726
}
2827

@@ -38,7 +37,7 @@ const stress = {
3837
}
3938
}
4039

41-
const counts = [1, 100, 1000, 10000]
40+
const counts = [1, 100, 1000]
4241
const benchmarks = []
4342
for (const count of counts) {
4443
const c = { count }

benchmarks/runner/benchmarks/from-entry.js renamed to benchmarks/from-entry.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const Log = require('../../../src/log')
2-
const startIPFS = require('./utils/start-ipfs')
1+
const Log = require('../src/log')
2+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
33
const createLog = require('./utils/create-log')
44

55
const base = {
66
prepare: async function () {
7-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/fromEntry/ipfs')
8-
const { log, access, identity } = await createLog(ipfs, 'A')
7+
const ipfsd = await startIpfs('js-ipfs', config)
8+
const { log, access, identity } = await createLog(ipfsd.api, 'A')
99
const refCount = 64
1010
process.stdout.clearLine()
1111
for (let i = 1; i < this.count + 1; i++) {
1212
process.stdout.write(`\r${this.name} / Preparing / Writing: ${i}/${this.count}`)
1313
await log.append('hello' + i, refCount)
1414
}
1515

16-
return { log, ipfs, repo, access, identity }
16+
return { log, ipfsd, access, identity }
1717
},
18-
cycle: async function ({ log, ipfs, access, identity }) {
19-
await Log.fromEntry(ipfs, identity, log.heads, { access })
18+
cycle: async function ({ log, ipfsd, access, identity }) {
19+
await Log.fromEntry(ipfsd.api, identity, log.heads, { access })
2020
},
21-
teardown: async function ({ repo }) {
22-
await repo.close()
21+
teardown: async function ({ ipfsd }) {
22+
await stopIpfs(ipfsd)
2323
}
2424
}
2525

@@ -35,7 +35,7 @@ const stress = {
3535
}
3636
}
3737

38-
const counts = [1, 100, 1000, 10000]
38+
const counts = [1, 100, 1000]
3939
const benchmarks = []
4040
for (const count of counts) {
4141
const c = { count }

benchmarks/runner/benchmarks/from-multihash.js renamed to benchmarks/from-multihash.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
3-
const Log = require('../../../src/log')
3+
const Log = require('../src/log')
44

55
const base = {
66
prepare: async function () {
7-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/fromMultihash/ipfs')
8-
const { log, access, identity } = await createLog(ipfs, 'A')
7+
const ipfsd = await startIpfs('js-ipfs', config)
8+
const { log, access, identity } = await createLog(ipfsd.api, 'A')
99
const refCount = 64
1010
process.stdout.clearLine()
1111
for (let i = 1; i < this.count + 1; i++) {
@@ -14,13 +14,13 @@ const base = {
1414
}
1515

1616
const multihash = await log.toMultihash()
17-
return { ipfs, repo, access, identity, log, multihash }
17+
return { ipfsd, access, identity, log, multihash }
1818
},
19-
cycle: async function ({ log, access, identity, ipfs, multihash }) {
20-
await Log.fromMultihash(ipfs, identity, multihash, { access })
19+
cycle: async function ({ log, access, identity, ipfsd, multihash }) {
20+
await Log.fromMultihash(ipfsd.api, identity, multihash, { access })
2121
},
22-
teardown: async function ({ repo }) {
23-
await repo.close()
22+
teardown: async function ({ ipfsd }) {
23+
await stopIpfs(ipfsd)
2424
}
2525
}
2626

@@ -36,7 +36,7 @@ const stress = {
3636
}
3737
}
3838

39-
const counts = [1, 100, 1000, 10000]
39+
const counts = [1, 100, 1000]
4040
const benchmarks = []
4141
for (const count of counts) {
4242
const c = { count }
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
33

44
const base = {
55
prepare: async function () {
6-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/ipfs')
7-
const { log } = await createLog(ipfs, 'A')
6+
const ipfsd = await startIpfs('js-ipfs', config)
7+
const { log } = await createLog(ipfsd.api, 'A')
88

99
process.stdout.clearLine()
1010
let entry
@@ -13,13 +13,13 @@ const base = {
1313
entry = await log.append(`Hello World: ${i}`)
1414
}
1515

16-
return { log, repo, entry }
16+
return { log, ipfsd, entry }
1717
},
1818
cycle: async function ({ log, entry }) {
1919
return log.get(entry.hash)
2020
},
21-
teardown: async function ({ repo }) {
22-
await repo.close()
21+
teardown: async function ({ ipfsd }) {
22+
await stopIpfs(ipfsd)
2323
}
2424
}
2525

@@ -35,7 +35,7 @@ const stress = {
3535
}
3636
}
3737

38-
const counts = [1, 100, 1000, 10000]
38+
const counts = [1, 100, 1000]
3939
const benchmarks = []
4040
for (const count of counts) {
4141
const c = { count }
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
33

44
const base = {
55
prepare: async function () {
6-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/ipfs')
7-
const { log } = await createLog(ipfs, 'A')
6+
const ipfsd = await startIpfs('js-ipfs', config)
7+
const { log } = await createLog(ipfsd.api, 'A')
88

99
process.stdout.clearLine()
1010
let entry
@@ -13,13 +13,13 @@ const base = {
1313
entry = await log.append(`Hello World: ${i}`)
1414
}
1515

16-
return { log, repo, entry }
16+
return { log, ipfsd, entry }
1717
},
1818
cycle: async function ({ log, entry }) {
1919
return log.has(entry)
2020
},
21-
teardown: async function ({ repo }) {
22-
await repo.close()
21+
teardown: async function ({ ipfsd }) {
22+
await stopIpfs(ipfsd)
2323
}
2424
}
2525

@@ -35,7 +35,7 @@ const stress = {
3535
}
3636
}
3737

38-
const counts = [1, 100, 1000, 10000]
38+
const counts = [1, 100, 1000]
3939
const benchmarks = []
4040
for (const count of counts) {
4141
const c = { count }
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
const startIPFS = require('./utils/start-ipfs')
1+
const { startIpfs, stopIpfs, config } = require('orbit-db-test-utils')
22
const createLog = require('./utils/create-log')
33

44
const base = {
55
prepare: async function () {
6-
const { ipfs, repo } = await startIPFS('./ipfs-log-benchmarks/ipfs')
7-
const { log } = await createLog(ipfs, 'A')
6+
const ipfsd = await startIpfs('js-ipfs', config)
7+
const { log } = await createLog(ipfsd.api, 'A')
88

99
process.stdout.clearLine()
1010
for (let i = 1; i < this.count + 1; i++) {
1111
process.stdout.write(`\r${this.name} / Preparing / Writing: ${i}/${this.count}`)
1212
await log.append(`Hello World: ${i}`)
1313
}
1414

15-
return { log, repo }
15+
return { log, ipfsd }
1616
},
1717
cycle: async function ({ log }) {
1818
return log.heads
1919
},
20-
teardown: async function ({ repo }) {
21-
await repo.close()
20+
teardown: async function ({ ipfsd }) {
21+
await stopIpfs(ipfsd)
2222
}
2323
}
2424

@@ -34,7 +34,7 @@ const stress = {
3434
}
3535
}
3636

37-
const counts = [1, 100, 1000, 10000]
37+
const counts = [1, 100, 1000]
3838
const benchmarks = []
3939
for (const count of counts) {
4040
const c = { count }

0 commit comments

Comments
 (0)