-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathconcat.perf.ts
68 lines (65 loc) · 1.53 KB
/
concat.perf.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { List } from "immutable";
import * as _ from "lodash";
import * as Finger from "@paldepind/finger-tree";
import { benchmark } from "./report";
import * as L from "../../dist/index";
import * as Lo from "./list-old/dist/index";
let left: any;
let right: any;
benchmark(
{
name: "concat",
description: "Concatenates two sequences of size n.",
input: [10, 50, 100, 250, 500, 1000, 5000, 10000]
},
{
List: {
before: n => {
left = L.range(0, n);
right = L.range(n, 2 * n);
},
run: () => L.concat(left, right)
},
"List, old": {
before: n => {
left = Lo.range(0, n);
right = Lo.range(n, 2 * n);
},
run: () => Lo.concat(left, right)
},
Lodash: {
before: n => {
left = _.range(0, n);
right = _.range(n, 2 * n);
},
run: () => _.concat(left, right)
},
"Array#concat": {
before: n => {
left = _.range(0, n);
right = _.range(n, 2 * n);
},
run: () => left.concat(right)
},
"Immutable.js": {
before: n => {
left = List(_.range(0, n));
right = List(_.range(n, 2 * n));
},
run: () => left.concat(right)
},
Finger: {
before: n => {
left = Finger.nil;
for (let i = 0; i < n; ++i) {
left = Finger.append(i, left);
}
right = Finger.nil;
for (let i = n; i < 2 * n; ++i) {
right = Finger.append(i, right);
}
},
run: () => Finger.concat(left, right)
}
}
);