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

Commit 49aa042

Browse files
authored
chore: update benchmark (#99)
1 parent af8607e commit 49aa042

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

benchmark/datastore-level/src/index.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,39 @@ async function testPut (): Promise<void> {
1212
console.info('simple put')
1313

1414
const suite = new Bench({
15-
iterations: 1
15+
iterations: 1,
16+
time: 100
1617
})
17-
suite.add('level put', async () => {
18+
suite.add('level put', async function () {
1819
for (let i = 0; i < BLOCKS; i++) {
1920
// @ts-expect-error
2021
await this.store.put(new Key(`/z/block-${i}`), Uint8Array.from([0, 1, 2, 3, 4, i]))
2122
}
2223
}, {
23-
async beforeEach () {
24+
beforeEach: async function () {
2425
// @ts-expect-error
2526
this.store = new LevelDatastore('hello-level-put')
2627
// @ts-expect-error
2728
await this.store.open()
2829
},
29-
async afterEach () {
30+
afterEach: async function () {
3031
// @ts-expect-error
3132
await this.store.close()
3233
}
3334
})
34-
suite.add('idb put', async () => {
35+
suite.add('idb put', async function () {
3536
for (let i = 0; i < BLOCKS; i++) {
3637
// @ts-expect-error
37-
await store.put(new Key(`/z/block-${i}`), Uint8Array.from([0, 1, 2, 3, 4, i]))
38+
await this.store.put(new Key(`/z/block-${i}`), Uint8Array.from([0, 1, 2, 3, 4, i]))
3839
}
3940
}, {
40-
async beforeEach () {
41+
beforeEach: async function () {
4142
// @ts-expect-error
4243
this.store = new IDBDatastore('hello-idb-put')
4344
// @ts-expect-error
4445
await this.store.open()
4546
},
46-
async afterEach () {
47+
afterEach: async function () {
4748
// @ts-expect-error
4849
await this.store.close()
4950
}
@@ -76,50 +77,51 @@ async function testGet (): Promise<void> {
7677
console.info('simple get')
7778

7879
const suite = new Bench({
79-
iterations: 1
80+
iterations: 1,
81+
time: 100
8082
})
81-
suite.add('level get', async () => {
83+
suite.add('level get', async function () {
8284
for (let i = 0; i < BLOCKS; i++) {
8385
// @ts-expect-error
8486
await this.store.get(new Key(`/z/block-${i}`))
8587
}
8688
}, {
87-
async beforeEach () {
89+
beforeEach: async function () {
8890
// @ts-expect-error
8991
this.store = new LevelDatastore('hello-level-get')
9092

93+
// @ts-expect-error
94+
await this.store.open()
95+
9196
for (let i = 0; i < BLOCKS; i++) {
9297
// @ts-expect-error
9398
await this.store.put(new Key(`/z/block-${i}`), Uint8Array.from([0, 1, 2, 3, 4, i]))
9499
}
95-
96-
// @ts-expect-error
97-
await this.store.open()
98100
},
99-
async afterEach () {
101+
afterEach: async function () {
100102
// @ts-expect-error
101103
await this.store.close()
102104
}
103105
})
104-
suite.add('idb get', async () => {
106+
suite.add('idb get', async function () {
105107
for (let i = 0; i < BLOCKS; i++) {
106108
// @ts-expect-error
107109
await this.store.get(new Key(`/z/block-${i}`))
108110
}
109111
}, {
110-
async beforeEach () {
112+
beforeEach: async function () {
111113
// @ts-expect-error
112114
this.store = new IDBDatastore('hello-idb-get')
113115

116+
// @ts-expect-error
117+
await this.store.open()
118+
114119
for (let i = 0; i < BLOCKS; i++) {
115120
// @ts-expect-error
116121
await this.store.put(new Key(`/z/block-${i}`), Uint8Array.from([0, 1, 2, 3, 4, i]))
117122
}
118-
119-
// @ts-expect-error
120-
await this.store.open()
121123
},
122-
async afterEach () {
124+
afterEach: async function () {
123125
// @ts-expect-error
124126
await this.store.close()
125127
}

0 commit comments

Comments
 (0)