@@ -37,33 +37,33 @@ const Benchmark = require('benchmark');
37
37
// PUSH
38
38
39
39
const PUSH = new Benchmark . Suite ( )
40
- . on ( 'start' , function ( ) {
40
+ . on ( 'start' , ( ) => {
41
41
console . log ( '\nPUSH\n==\n' ) ;
42
42
} )
43
- . add ( 'Array#push' , function ( ) {
43
+ . add ( 'Array#push' , ( ) => {
44
44
const a = [ ] ;
45
45
const _M = M ;
46
46
for ( let i = 0 ; i < _M ; ++ i ) a . push ( i ) ;
47
47
} )
48
- . add ( 'fingertree#addLast' , function ( ) {
48
+ . add ( 'fingertree#addLast' , ( ) => {
49
49
let t = fromArray ( [ ] ) ;
50
50
const _M = M ;
51
51
for ( let i = 0 ; i < _M ; ++ i ) t = t . addLast ( i ) ;
52
52
} )
53
- . add ( '@aureooms/js-fingertree#push' , function ( ) {
53
+ . add ( '@aureooms/js-fingertree#push' , ( ) => {
54
54
let t = empty ( COUNTER ) ;
55
55
const _M = M ;
56
56
for ( let i = 0 ; i < _M ; ++ i ) t = t . push ( i ) ;
57
57
} ) ;
58
58
59
59
if ( M <= 1000 )
60
- PUSH . add ( 'Mock#push' , function ( ) {
60
+ PUSH . add ( 'Mock#push' , ( ) => {
61
61
let m = [ ] ;
62
62
const _M = M ;
63
63
for ( let i = 0 ; i < _M ; ++ i ) m = m . concat ( [ i ] ) ;
64
64
} ) ;
65
65
66
- PUSH . on ( 'cycle' , function ( event ) {
66
+ PUSH . on ( 'cycle' , ( event ) => {
67
67
console . log ( String ( event . target ) ) ;
68
68
} )
69
69
. on ( 'complete' , function ( ) {
@@ -73,34 +73,34 @@ PUSH.on('cycle', function (event) {
73
73
74
74
// CONS
75
75
76
- const CONS = new Benchmark . Suite ( ) . on ( 'start' , function ( ) {
76
+ const CONS = new Benchmark . Suite ( ) . on ( 'start' , ( ) => {
77
77
console . log ( '\nCONS\n==\n' ) ;
78
78
} ) ;
79
79
80
80
if ( M <= 10000 )
81
- CONS . add ( 'Array#unshift' , function ( ) {
81
+ CONS . add ( 'Array#unshift' , ( ) => {
82
82
const a = [ ] ;
83
83
const _M = M ;
84
84
for ( let i = 0 ; i < _M ; ++ i ) a . unshift ( i ) ;
85
85
} ) ;
86
86
87
- CONS . add ( 'fingertree#addFirst' , function ( ) {
87
+ CONS . add ( 'fingertree#addFirst' , ( ) => {
88
88
let t = fromArray ( [ ] ) ;
89
89
const _M = M ;
90
90
for ( let i = 0 ; i < _M ; ++ i ) t = t . addFirst ( i ) ;
91
- } ) . add ( '@aureooms/js-fingertree#cons' , function ( ) {
91
+ } ) . add ( '@aureooms/js-fingertree#cons' , ( ) => {
92
92
let t = empty ( COUNTER ) ;
93
93
const _M = M ;
94
94
for ( let i = 0 ; i < _M ; ++ i ) t = t . cons ( i ) ;
95
95
} ) ;
96
96
if ( M <= 1000 )
97
- CONS . add ( 'Mock#cons' , function ( ) {
97
+ CONS . add ( 'Mock#cons' , ( ) => {
98
98
let m = [ ] ;
99
99
const _M = M ;
100
100
for ( let i = 0 ; i < _M ; ++ i ) m = [ i ] . concat ( m ) ;
101
101
} ) ;
102
102
103
- CONS . on ( 'cycle' , function ( event ) {
103
+ CONS . on ( 'cycle' , ( event ) => {
104
104
console . log ( String ( event . target ) ) ;
105
105
} )
106
106
. on ( 'complete' , function ( ) {
@@ -122,28 +122,28 @@ const setup = function () {
122
122
} ;
123
123
124
124
const INIT = new Benchmark . Suite ( )
125
- . on ( 'start' , function ( ) {
125
+ . on ( 'start' , ( ) => {
126
126
console . log ( '\nINIT\n==\n' ) ;
127
127
} )
128
128
. add (
129
129
'Array#pop' ,
130
- function ( ) {
130
+ ( ) => {
131
131
const _a = a . slice ( ) ;
132
132
for ( let i = 0 ; i < _M ; ++ i ) _a . pop ( ) ;
133
133
} ,
134
134
{ setup}
135
135
)
136
136
. add (
137
137
'fingertree#removeLast' ,
138
- function ( ) {
138
+ ( ) => {
139
139
let _t = qt ;
140
140
for ( let i = 0 ; i < _M ; ++ i ) _t = _t . removeLast ( ) ;
141
141
} ,
142
142
{ setup}
143
143
)
144
144
. add (
145
145
'@aureooms/js-fingertree#init' ,
146
- function ( ) {
146
+ ( ) => {
147
147
let _t = at ;
148
148
for ( let i = 0 ; i < _M ; ++ i ) _t = _t . init ( ) ;
149
149
} ,
@@ -153,17 +153,17 @@ const INIT = new Benchmark.Suite()
153
153
if ( M <= 1000 )
154
154
INIT . add (
155
155
'Mock#init' ,
156
- function ( ) {
156
+ ( ) => {
157
157
let _m = a ;
158
158
for ( let i = 0 ; i < _M ; ++ i ) _m = _m . slice ( 0 , - 1 ) ;
159
159
} ,
160
160
{ setup}
161
161
) ;
162
162
163
- INIT . on ( 'cycle' , function ( event ) {
163
+ INIT . on ( 'cycle' , ( event ) => {
164
164
console . log ( String ( event . target ) ) ;
165
165
} )
166
- . on ( 'error' , function ( event ) {
166
+ . on ( 'error' , ( event ) => {
167
167
console . dir ( event ) ;
168
168
} )
169
169
. on ( 'complete' , function ( ) {
@@ -173,14 +173,14 @@ INIT.on('cycle', function (event) {
173
173
174
174
// TAIL
175
175
176
- const TAIL = new Benchmark . Suite ( ) . on ( 'start' , function ( ) {
176
+ const TAIL = new Benchmark . Suite ( ) . on ( 'start' , ( ) => {
177
177
console . log ( '\nTAIL\n==\n' ) ;
178
178
} ) ;
179
179
180
180
if ( M <= 10000 )
181
181
TAIL . add (
182
182
'Array#shift' ,
183
- function ( ) {
183
+ ( ) => {
184
184
const _a = a . slice ( ) ;
185
185
for ( let i = 0 ; i < _M ; ++ i ) _a . shift ( ) ;
186
186
} ,
@@ -189,14 +189,14 @@ if (M <= 10000)
189
189
190
190
TAIL . add (
191
191
'fingertree#removeLast' ,
192
- function ( ) {
192
+ ( ) => {
193
193
let _t = qt ;
194
194
for ( let i = 0 ; i < _M ; ++ i ) _t = _t . removeFirst ( ) ;
195
195
} ,
196
196
{ setup}
197
197
) . add (
198
198
'@aureooms/js-fingertree#init' ,
199
- function ( ) {
199
+ ( ) => {
200
200
let _t = at ;
201
201
for ( let i = 0 ; i < _M ; ++ i ) _t = _t . tail ( ) ;
202
202
} ,
@@ -206,17 +206,17 @@ TAIL.add(
206
206
if ( M <= 1000 )
207
207
TAIL . add (
208
208
'Mock#init' ,
209
- function ( ) {
209
+ ( ) => {
210
210
let _m = a ;
211
211
for ( let i = 0 ; i < _M ; ++ i ) _m = _m . slice ( 1 ) ;
212
212
} ,
213
213
{ setup}
214
214
) ;
215
215
216
- TAIL . on ( 'cycle' , function ( event ) {
216
+ TAIL . on ( 'cycle' , ( event ) => {
217
217
console . log ( String ( event . target ) ) ;
218
218
} )
219
- . on ( 'error' , function ( event ) {
219
+ . on ( 'error' , ( event ) => {
220
220
console . dir ( event ) ;
221
221
} )
222
222
. on ( 'complete' , function ( ) {
@@ -227,12 +227,12 @@ TAIL.on('cycle', function (event) {
227
227
// APPEND
228
228
229
229
const APPEND = new Benchmark . Suite ( )
230
- . on ( 'start' , function ( ) {
230
+ . on ( 'start' , ( ) => {
231
231
console . log ( '\nAPPEND\n==\n' ) ;
232
232
} )
233
233
. add (
234
234
'@aureooms/js-fingertree#append' ,
235
- function ( ) {
235
+ ( ) => {
236
236
at . append ( range ( M ) ) ;
237
237
} ,
238
238
{ setup}
@@ -241,13 +241,13 @@ const APPEND = new Benchmark.Suite()
241
241
if ( M <= 1000 )
242
242
APPEND . add (
243
243
'Mock#append' ,
244
- function ( ) {
244
+ ( ) => {
245
245
a . concat ( Array . from ( range ( M ) ) ) ;
246
246
} ,
247
247
{ setup}
248
248
) ;
249
249
250
- APPEND . on ( 'cycle' , function ( event ) {
250
+ APPEND . on ( 'cycle' , ( event ) => {
251
251
console . log ( String ( event . target ) ) ;
252
252
} )
253
253
. on ( 'complete' , function ( ) {
@@ -258,12 +258,12 @@ APPEND.on('cycle', function (event) {
258
258
// PREPEND
259
259
260
260
const PREPEND = new Benchmark . Suite ( )
261
- . on ( 'start' , function ( ) {
261
+ . on ( 'start' , ( ) => {
262
262
console . log ( '\nPREPEND\n==\n' ) ;
263
263
} )
264
264
. add (
265
265
'@aureooms/js-fingertree#prepend' ,
266
- function ( ) {
266
+ ( ) => {
267
267
at . prepend ( range ( M ) ) ;
268
268
} ,
269
269
{ setup}
@@ -272,13 +272,13 @@ const PREPEND = new Benchmark.Suite()
272
272
if ( M <= 1000 )
273
273
PREPEND . add (
274
274
'Mock#prepend' ,
275
- function ( ) {
275
+ ( ) => {
276
276
Array . from ( range ( M ) ) . concat ( a ) ;
277
277
} ,
278
278
{ setup}
279
279
) ;
280
280
281
- PREPEND . on ( 'cycle' , function ( event ) {
281
+ PREPEND . on ( 'cycle' , ( event ) => {
282
282
console . log ( String ( event . target ) ) ;
283
283
} )
284
284
. on ( 'complete' , function ( ) {
@@ -289,19 +289,19 @@ PREPEND.on('cycle', function (event) {
289
289
// FROM
290
290
291
291
new Benchmark . Suite ( )
292
- . on ( 'start' , function ( ) {
292
+ . on ( 'start' , ( ) => {
293
293
console . log ( '\nFROM\n==\n' ) ;
294
294
} )
295
- . add ( 'fingertree.fromArray' , function ( ) {
295
+ . add ( 'fingertree.fromArray' , ( ) => {
296
296
fromArray ( Array . from ( range ( M ) ) ) ;
297
297
} )
298
- . add ( '@aureooms/js-fingertree.from' , function ( ) {
298
+ . add ( '@aureooms/js-fingertree.from' , ( ) => {
299
299
from ( COUNTER , range ( M ) ) ;
300
300
} )
301
- . add ( 'Mock.from' , function ( ) {
301
+ . add ( 'Mock.from' , ( ) => {
302
302
Array . from ( range ( M ) ) ;
303
303
} )
304
- . on ( 'cycle' , function ( event ) {
304
+ . on ( 'cycle' , ( event ) => {
305
305
console . log ( String ( event . target ) ) ;
306
306
} )
307
307
. on ( 'complete' , function ( ) {
@@ -312,28 +312,28 @@ new Benchmark.Suite()
312
312
// SPLIT
313
313
314
314
const SPLIT = new Benchmark . Suite ( )
315
- . on ( 'start' , function ( ) {
315
+ . on ( 'start' , ( ) => {
316
316
console . log ( '\nSPLIT\n==\n' ) ;
317
317
} )
318
318
. add (
319
319
'fingertree#split' ,
320
- function ( ) {
320
+ ( ) => {
321
321
const _M = M ;
322
322
const _qt = qt ;
323
323
for ( let i = 0 ; i < _M ; ++ i )
324
- _qt . split ( function ( m ) {
324
+ _qt . split ( ( m ) => {
325
325
return m > i ;
326
326
} ) ;
327
327
} ,
328
328
{ setup}
329
329
)
330
330
. add (
331
331
'@aureooms/js-fingertree#split' ,
332
- function ( ) {
332
+ ( ) => {
333
333
const _M = M ;
334
334
const _at = at ;
335
335
for ( let i = 0 ; i < _M ; ++ i )
336
- _at . split ( function ( m ) {
336
+ _at . split ( ( m ) => {
337
337
return m > i ;
338
338
} ) ;
339
339
} ,
@@ -343,7 +343,7 @@ const SPLIT = new Benchmark.Suite()
343
343
if ( M < 1000 )
344
344
SPLIT . add (
345
345
'Mock#split' ,
346
- function ( ) {
346
+ ( ) => {
347
347
const _M = M ;
348
348
const _a = a ;
349
349
for ( let i = 0 ; i < _M ; ++ i ) {
@@ -354,7 +354,7 @@ if (M < 1000)
354
354
{ setup}
355
355
) ;
356
356
357
- SPLIT . on ( 'cycle' , function ( event ) {
357
+ SPLIT . on ( 'cycle' , ( event ) => {
358
358
console . log ( String ( event . target ) ) ;
359
359
} )
360
360
. on ( 'complete' , function ( ) {
@@ -365,14 +365,14 @@ SPLIT.on('cycle', function (event) {
365
365
// CONCAT
366
366
367
367
new Benchmark . Suite ( )
368
- . on ( 'start' , function ( ) {
368
+ . on ( 'start' , ( ) => {
369
369
console . log ( '\nCONCAT\n==\n' ) ;
370
370
} )
371
371
// I had to put this version first because the second uses a lot of memory.
372
372
// This is probably because qiao/fingetree.js keeps references of used thunks.
373
373
. add (
374
374
'@aureooms/js-fingertree#concat' ,
375
- function ( ) {
375
+ ( ) => {
376
376
const _M = M ;
377
377
const _s = splits ;
378
378
for ( let i = 0 ; i < _M ; ++ i ) _s [ i ] [ 0 ] . concat ( _s [ i ] [ 1 ] ) ;
@@ -383,7 +383,7 @@ new Benchmark.Suite()
383
383
const splits = [ ] ;
384
384
for ( let i = 0 ; i < M ; ++ i ) {
385
385
splits . push (
386
- t . split ( function ( m ) {
386
+ t . split ( ( m ) => {
387
387
return m > i ;
388
388
} )
389
389
) ;
@@ -396,7 +396,7 @@ new Benchmark.Suite()
396
396
)
397
397
. add (
398
398
'fingertree#concat' ,
399
- function ( ) {
399
+ ( ) => {
400
400
const _M = M ;
401
401
const _s = splits ;
402
402
for ( let i = 0 ; i < _M ; ++ i ) _s [ i ] [ 0 ] . concat ( _s [ i ] [ 1 ] ) ;
@@ -407,7 +407,7 @@ new Benchmark.Suite()
407
407
const splits = [ ] ;
408
408
for ( let i = 0 ; i < M ; ++ i ) {
409
409
splits . push (
410
- t . split ( function ( m ) {
410
+ t . split ( ( m ) => {
411
411
return m > i ;
412
412
} )
413
413
) ;
@@ -418,7 +418,7 @@ new Benchmark.Suite()
418
418
}
419
419
}
420
420
)
421
- . on ( 'cycle' , function ( event ) {
421
+ . on ( 'cycle' , ( event ) => {
422
422
console . log ( String ( event . target ) ) ;
423
423
} )
424
424
. on ( 'complete' , function ( ) {
0 commit comments