@@ -12,38 +12,39 @@ async function testPut (): Promise<void> {
12
12
console . info ( 'simple put' )
13
13
14
14
const suite = new Bench ( {
15
- iterations : 1
15
+ iterations : 1 ,
16
+ time : 100
16
17
} )
17
- suite . add ( 'level put' , async ( ) => {
18
+ suite . add ( 'level put' , async function ( ) {
18
19
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
19
20
// @ts -expect-error
20
21
await this . store . put ( new Key ( `/z/block-${ i } ` ) , Uint8Array . from ( [ 0 , 1 , 2 , 3 , 4 , i ] ) )
21
22
}
22
23
} , {
23
- async beforeEach ( ) {
24
+ beforeEach : async function ( ) {
24
25
// @ts -expect-error
25
26
this . store = new LevelDatastore ( 'hello-level-put' )
26
27
// @ts -expect-error
27
28
await this . store . open ( )
28
29
} ,
29
- async afterEach ( ) {
30
+ afterEach : async function ( ) {
30
31
// @ts -expect-error
31
32
await this . store . close ( )
32
33
}
33
34
} )
34
- suite . add ( 'idb put' , async ( ) => {
35
+ suite . add ( 'idb put' , async function ( ) {
35
36
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
36
37
// @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 ] ) )
38
39
}
39
40
} , {
40
- async beforeEach ( ) {
41
+ beforeEach : async function ( ) {
41
42
// @ts -expect-error
42
43
this . store = new IDBDatastore ( 'hello-idb-put' )
43
44
// @ts -expect-error
44
45
await this . store . open ( )
45
46
} ,
46
- async afterEach ( ) {
47
+ afterEach : async function ( ) {
47
48
// @ts -expect-error
48
49
await this . store . close ( )
49
50
}
@@ -76,50 +77,51 @@ async function testGet (): Promise<void> {
76
77
console . info ( 'simple get' )
77
78
78
79
const suite = new Bench ( {
79
- iterations : 1
80
+ iterations : 1 ,
81
+ time : 100
80
82
} )
81
- suite . add ( 'level get' , async ( ) => {
83
+ suite . add ( 'level get' , async function ( ) {
82
84
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
83
85
// @ts -expect-error
84
86
await this . store . get ( new Key ( `/z/block-${ i } ` ) )
85
87
}
86
88
} , {
87
- async beforeEach ( ) {
89
+ beforeEach : async function ( ) {
88
90
// @ts -expect-error
89
91
this . store = new LevelDatastore ( 'hello-level-get' )
90
92
93
+ // @ts -expect-error
94
+ await this . store . open ( )
95
+
91
96
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
92
97
// @ts -expect-error
93
98
await this . store . put ( new Key ( `/z/block-${ i } ` ) , Uint8Array . from ( [ 0 , 1 , 2 , 3 , 4 , i ] ) )
94
99
}
95
-
96
- // @ts -expect-error
97
- await this . store . open ( )
98
100
} ,
99
- async afterEach ( ) {
101
+ afterEach : async function ( ) {
100
102
// @ts -expect-error
101
103
await this . store . close ( )
102
104
}
103
105
} )
104
- suite . add ( 'idb get' , async ( ) => {
106
+ suite . add ( 'idb get' , async function ( ) {
105
107
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
106
108
// @ts -expect-error
107
109
await this . store . get ( new Key ( `/z/block-${ i } ` ) )
108
110
}
109
111
} , {
110
- async beforeEach ( ) {
112
+ beforeEach : async function ( ) {
111
113
// @ts -expect-error
112
114
this . store = new IDBDatastore ( 'hello-idb-get' )
113
115
116
+ // @ts -expect-error
117
+ await this . store . open ( )
118
+
114
119
for ( let i = 0 ; i < BLOCKS ; i ++ ) {
115
120
// @ts -expect-error
116
121
await this . store . put ( new Key ( `/z/block-${ i } ` ) , Uint8Array . from ( [ 0 , 1 , 2 , 3 , 4 , i ] ) )
117
122
}
118
-
119
- // @ts -expect-error
120
- await this . store . open ( )
121
123
} ,
122
- async afterEach ( ) {
124
+ afterEach : async function ( ) {
123
125
// @ts -expect-error
124
126
await this . store . close ( )
125
127
}
0 commit comments