Skip to content

Commit 85ef6df

Browse files
😒 chore(benchmark): Update.
1 parent 31132cb commit 85ef6df

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

_benchmark/README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,52 @@
33
There are three different benchmarks. The main one is tree.js which benchmarks
44
finger trees operations. The two others are there for comparison.
55

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+
612
## Finger trees benchmark (persistent data structure)
713

814
```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
1626
```
1727

1828
## Arrays benchmark (non-persistent)
1929

2030
```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
2637
split: no time since you cannot splice an array more than once
27-
init: 15ms
38+
total: 1.703s
2839
```
2940

3041
## Arrays benchmark using persistent operations (persistent)
3142

3243
It is clear that the copy operation is the most expensive (2 copies in split).
3344

3445
```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)
4254
```

_benchmark/array.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ for (i = 0; i < length; ++i) {
2828

2929
console.timeEnd('push');
3030

31-
console.log('split: no time since you cannot splice an array more than once');
32-
3331
console.time('init');
3432
for (i = 0; i < length; ++i) {
3533
t.pop();
3634
}
3735

3836
console.timeEnd('init');
37+
38+
console.log('split: no time since you cannot splice an array more than once');
3939
console.timeEnd('total');

_benchmark/placebo.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
let t;
2+
let _t;
23
let i;
34
const length = 100000;
45

@@ -28,18 +29,21 @@ for (i = 0; i < length; ++i) {
2829

2930
console.timeEnd('push');
3031

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;
3833

3934
console.time('init');
4035
for (i = 0; i < length; ++i) {
4136
t = t.slice(0, -1);
4237
}
4338

4439
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+
4549
console.timeEnd('total');

0 commit comments

Comments
 (0)