@@ -18,6 +18,7 @@ const {
18
18
and,
19
19
or,
20
20
equal,
21
+ slowEqual,
21
22
count,
22
23
toCallback,
23
24
toPullStream,
@@ -169,6 +170,110 @@ test('core indexes', (t) => {
169
170
)
170
171
} )
171
172
173
+ const slowEqualHugeIndexQuery = ( cb ) => {
174
+ query (
175
+ fromDB ( db ) ,
176
+ where ( slowEqual ( 'value.content.type' , 'post' ) ) ,
177
+ toCallback ( ( err , msgs ) => {
178
+ if ( err ) {
179
+ cb ( err )
180
+ } else if ( msgs . length !== 23310 ) {
181
+ cb ( new Error ( 'msgs.length is wrong: ' + msgs . length ) )
182
+ }
183
+ cb ( )
184
+ } )
185
+ )
186
+ }
187
+
188
+ test ( 'slowEqual one huge index (first run)' , ( t ) => {
189
+ runBenchmark (
190
+ 'Query 1 big index with slowEqual (1st run)' ,
191
+ slowEqualHugeIndexQuery ,
192
+ ( cb ) => {
193
+ closeLog ( ( err ) => {
194
+ if ( err ) cb ( err )
195
+ else getJitdbReady ( cb )
196
+ } )
197
+ } ,
198
+ ( err , result ) => {
199
+ if ( err ) {
200
+ t . fail ( err )
201
+ } else {
202
+ fs . appendFileSync ( reportPath , result )
203
+ t . pass ( result )
204
+ }
205
+ t . end ( )
206
+ }
207
+ )
208
+ } )
209
+
210
+ test ( 'slowEqual one huge index (second run)' , ( t ) => {
211
+ runBenchmark (
212
+ 'Query 1 big index with slowEqual (2nd run)' ,
213
+ slowEqualHugeIndexQuery ,
214
+ ( cb ) => {
215
+ closeLog ( ( err ) => {
216
+ if ( err ) cb ( err )
217
+ else getJitdbReady ( ( err2 ) => {
218
+ if ( err2 ) cb ( err2 )
219
+ else slowEqualHugeIndexQuery ( cb )
220
+ } )
221
+ } )
222
+ } ,
223
+ ( err , result ) => {
224
+ if ( err ) {
225
+ t . fail ( err )
226
+ } else {
227
+ fs . appendFileSync ( reportPath , result )
228
+ t . pass ( result )
229
+ }
230
+ t . end ( )
231
+ }
232
+ )
233
+ } )
234
+
235
+ test ( 'slowEqual count one huge index (third run)' , ( t ) => {
236
+ runBenchmark (
237
+ 'Query 1 big index with slowEqual (3rd run)' ,
238
+ ( cb ) => {
239
+ query (
240
+ fromDB ( db ) ,
241
+ where ( slowEqual ( 'value.content.type' , 'post' ) ) ,
242
+ count ( ) ,
243
+ toCallback ( ( err , total ) => {
244
+ if ( err ) {
245
+ cb ( err )
246
+ } else if ( total !== 23310 ) {
247
+ cb ( new Error ( 'total is wrong: ' + total ) )
248
+ }
249
+ cb ( )
250
+ } )
251
+ )
252
+ } ,
253
+ ( cb ) => {
254
+ closeLog ( ( err ) => {
255
+ if ( err ) cb ( err )
256
+ else getJitdbReady ( ( err2 ) => {
257
+ if ( err2 ) cb ( err2 )
258
+ else slowEqualHugeIndexQuery ( ( err3 ) => {
259
+ if ( err3 ) cb ( err3 )
260
+ else slowEqualHugeIndexQuery ( cb )
261
+ } )
262
+ } )
263
+ } )
264
+ } ,
265
+ ( err , result ) => {
266
+ if ( err ) {
267
+ t . fail ( err )
268
+ } else {
269
+ fs . appendFileSync ( reportPath , result )
270
+ t . pass ( result )
271
+ }
272
+ t . end ( )
273
+ }
274
+ )
275
+ } )
276
+
172
277
const runHugeIndexQuery = ( cb ) => {
173
278
query (
174
279
fromDB ( db ) ,
0 commit comments