@@ -203,11 +203,11 @@ results of this test:
203
203
const ar = observable ( [ 0 ] )
204
204
const findLastIndexOfZero = computed ( function ( ) {
205
205
aCalc ++
206
- return ar . findLastIndex ( x => x === 0 ) ;
206
+ return ar . findLastIndex ( x => x === 0 )
207
207
} )
208
208
const lastIndexOfZero = computed ( function ( ) {
209
209
bCalc ++
210
- return ar . lastIndexOf ( 0 ) ;
210
+ return ar . lastIndexOf ( 0 )
211
211
} )
212
212
mobx . observe ( findLastIndexOfZero , voidObserver , true )
213
213
mobx . observe ( lastIndexOfZero , voidObserver , true )
@@ -225,9 +225,7 @@ results of this test:
225
225
226
226
const end = now ( )
227
227
228
- log (
229
- "Array findLastIndex loop - Updated in " + ( end - start ) + " ms."
230
- )
228
+ log ( "Array findLastIndex loop - Updated in " + ( end - start ) + " ms." )
231
229
t . end ( )
232
230
} )
233
231
@@ -552,6 +550,146 @@ results of this test:
552
550
t . end ( )
553
551
} )
554
552
553
+ test ( `${ version } - Set: initializing` , function ( t ) {
554
+ gc ( )
555
+ const iterationsCount = 100000
556
+ let i
557
+
558
+ const start = Date . now ( )
559
+ for ( i = 0 ; i < iterationsCount ; i ++ ) {
560
+ mobx . observable . set ( )
561
+ }
562
+ const end = Date . now ( )
563
+ log ( "Initilizing " + iterationsCount + " maps: " + ( end - start ) + " ms." )
564
+ t . end ( )
565
+ } )
566
+
567
+ test ( `${ version } - Set: setting and deleting properties` , function ( t ) {
568
+ gc ( )
569
+ const iterationsCount = 1000
570
+ const propertiesCount = 10000
571
+ const set = mobx . observable . set ( )
572
+ let i
573
+ let p
574
+
575
+ const start = Date . now ( )
576
+ for ( i = 0 ; i < iterationsCount ; i ++ ) {
577
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
578
+ set . add ( "" + p )
579
+ }
580
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
581
+ set . delete ( "" + p )
582
+ }
583
+ }
584
+ const end = Date . now ( )
585
+
586
+ log (
587
+ "Setting and deleting " +
588
+ propertiesCount +
589
+ " set properties " +
590
+ iterationsCount +
591
+ " times: " +
592
+ ( end - start ) +
593
+ " ms."
594
+ )
595
+ t . end ( )
596
+ } )
597
+
598
+ test ( `${ version } - Set: looking up properties` , function ( t ) {
599
+ gc ( )
600
+ const iterationsCount = 1000
601
+ const propertiesCount = 10000
602
+ const set = mobx . observable . set ( )
603
+ let i
604
+ let p
605
+
606
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
607
+ set . add ( "" + p )
608
+ }
609
+
610
+ const start = Date . now ( )
611
+ for ( i = 0 ; i < iterationsCount ; i ++ ) {
612
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
613
+ set . has ( "" + p )
614
+ }
615
+ }
616
+ const end = Date . now ( )
617
+
618
+ log (
619
+ "Looking up " +
620
+ propertiesCount +
621
+ " set properties " +
622
+ iterationsCount +
623
+ " times: " +
624
+ ( end - start ) +
625
+ " ms."
626
+ )
627
+ t . end ( )
628
+ } )
629
+
630
+ test ( `${ version } - Set: iterator helpers` , function ( t ) {
631
+ gc ( )
632
+ const iterationsCount = 1000
633
+ const propertiesCount = 10000
634
+ const set = mobx . observable . set ( )
635
+ let i
636
+ let p
637
+
638
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
639
+ set . add ( "" + p )
640
+ }
641
+
642
+ const start = Date . now ( )
643
+ for ( i = 0 ; i < iterationsCount ; i ++ ) {
644
+ set . entries ( ) . take ( 1 )
645
+ }
646
+ const end = Date . now ( )
647
+
648
+ log (
649
+ "Single take out of" +
650
+ propertiesCount +
651
+ " set properties " +
652
+ iterationsCount +
653
+ " times: " +
654
+ ( end - start ) +
655
+ " ms."
656
+ )
657
+ t . end ( )
658
+ } )
659
+
660
+ test ( `${ version } - Set: conversion to array` , function ( t ) {
661
+ gc ( )
662
+ const iterationsCount = 1000
663
+ const propertiesCount = 10000
664
+ const set = mobx . observable . set ( )
665
+ let i
666
+ let p
667
+
668
+ for ( p = 0 ; p < propertiesCount ; p ++ ) {
669
+ set . add ( "" + p )
670
+ }
671
+
672
+ const start = Date . now ( )
673
+ for ( i = 0 ; i < iterationsCount ; i ++ ) {
674
+ Array . from ( set . keys ( ) )
675
+ Array . from ( set . values ( ) )
676
+ Array . from ( set . entries ( ) )
677
+ ; [ ...set ]
678
+ }
679
+ const end = Date . now ( )
680
+
681
+ log (
682
+ "Converting " +
683
+ propertiesCount +
684
+ " set properties into an array" +
685
+ iterationsCount +
686
+ " times: " +
687
+ ( end - start ) +
688
+ " ms."
689
+ )
690
+ t . end ( )
691
+ } )
692
+
555
693
test ( `${ version } - Map: initializing` , function ( t ) {
556
694
gc ( )
557
695
const iterationsCount = 100000
0 commit comments