File tree Expand file tree Collapse file tree 3 files changed +45
-29
lines changed Expand file tree Collapse file tree 3 files changed +45
-29
lines changed Original file line number Diff line number Diff line change 3
3
There are three different benchmarks. The main one is tree.js which benchmarks
4
4
finger trees operations. The two others are there for comparison.
5
5
6
+ > Run on a X1 Yoga 4th Gen.
7
+ > CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz.
8
+ > Memory: 2x 8192 MB 2133 MT/s LPDDR3 (Samsung)
9
+ > Linux: 5.7.6-arch1-1
10
+ > Node: v14.5.0
11
+
6
12
## Finger trees benchmark (persistent data structure)
7
13
8
14
``` sh
9
- $ node benchmark/tree.js
10
- number of operations: 100000
11
- cons: 101ms
12
- tail: 200ms
13
- push: 76ms
14
- split: 1281ms
15
- init: 172ms
15
+ $ node _benchmark/tree.js
16
+ number of operations: 100000
17
+ cons: 26.863ms
18
+ tail: 33.629ms
19
+ push: 18.745ms
20
+ init: 30.984ms
21
+ prepend: 30.342ms
22
+ append: 26.214ms
23
+ split: 398.124ms
24
+ concat: 57.936ms
25
+ total: 629ms
16
26
```
17
27
18
28
## Arrays benchmark (non-persistent)
19
29
20
30
``` sh
21
- $ node benchmark/array.js
22
- number of operations: 100000
23
- cons: 6994ms
24
- tail: 34ms
25
- push: 15ms
31
+ $ node _benchmark/array.js
32
+ number of operations: 100000
33
+ cons: 833.49ms
34
+ tail: 864.188ms
35
+ push: 3.38ms
36
+ init: 1.897ms
26
37
split: no time since you cannot splice an array more than once
27
- init: 15ms
38
+ total: 1.703s
28
39
```
29
40
30
41
## Arrays benchmark using persistent operations (persistent)
31
42
32
43
It is clear that the copy operation is the most expensive (2 copies in split).
33
44
34
45
``` sh
35
- $ node benchmark/placebo.js
36
- number of operations: 100000
37
- cons: 27033ms
38
- tail: 26686ms
39
- push: 26821ms
40
- split: 50553ms
41
- init: 26891ms
46
+ $ node _benchmark/placebo.js
47
+ number of operations: 100000
48
+ cons: 15.374s
49
+ tail: 15.541s
50
+ push: 17.310s
51
+ init: 18.797s
52
+ split: 42.298s
53
+ total: 1:49.325 (m:ss.mmm)
42
54
```
Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ for (i = 0; i < length; ++i) {
28
28
29
29
console . timeEnd ( 'push' ) ;
30
30
31
- console . log ( 'split: no time since you cannot splice an array more than once' ) ;
32
-
33
31
console . time ( 'init' ) ;
34
32
for ( i = 0 ; i < length ; ++ i ) {
35
33
t . pop ( ) ;
36
34
}
37
35
38
36
console . timeEnd ( 'init' ) ;
37
+
38
+ console . log ( 'split: no time since you cannot splice an array more than once' ) ;
39
39
console . timeEnd ( 'total' ) ;
Original file line number Diff line number Diff line change 1
1
let t ;
2
+ let _t ;
2
3
let i ;
3
4
const length = 100000 ;
4
5
@@ -28,18 +29,21 @@ for (i = 0; i < length; ++i) {
28
29
29
30
console . timeEnd ( 'push' ) ;
30
31
31
- console . time ( 'split' ) ;
32
- for ( i = 0 ; i < length ; ++ i ) {
33
- t . slice ( 0 , i ) ;
34
- t . slice ( i ) ;
35
- }
36
-
37
- console . timeEnd ( 'split' ) ;
32
+ _t = t ;
38
33
39
34
console . time ( 'init' ) ;
40
35
for ( i = 0 ; i < length ; ++ i ) {
41
36
t = t . slice ( 0 , - 1 ) ;
42
37
}
43
38
44
39
console . timeEnd ( 'init' ) ;
40
+
41
+ console . time ( 'split' ) ;
42
+ for ( i = 0 ; i < length ; ++ i ) {
43
+ _t . slice ( 0 , i ) ;
44
+ _t . slice ( i ) ;
45
+ }
46
+
47
+ console . timeEnd ( 'split' ) ;
48
+
45
49
console . timeEnd ( 'total' ) ;
You can’t perform that action at this time.
0 commit comments