-
Notifications
You must be signed in to change notification settings - Fork 51
/
insert.perf.ts
57 lines (53 loc) · 1.11 KB
/
insert.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
import { benchmark } from "./report";
import * as Immutable from "immutable";
import * as R from "ramda";
import * as mori from "mori";
import * as L from "../../dist/index";
import * as Lo from "./list-old/dist/index";
let idx = 0;
let l;
benchmark(
{
name: "insert",
description: "Insert an element in the middle of a sequence.",
input: [10, 50, 100, 250, 500, 1000, 5000, 10000]
},
{
List: {
before: to => {
l = L.range(0, to);
idx = (to / 2) | 0;
},
run: () => {
const l1 = L.insert(idx, 0, l);
}
},
"List, old": {
before: to => {
l = Lo.range(0, to);
idx = (to / 2) | 0;
},
run: () => {
const l1 = Lo.insert(idx, 0, l);
}
},
"Immutable.js": {
before: to => {
l = Immutable.Range(0, to).toList();
idx = (to / 2) | 0;
},
run: () => {
const l1 = l.insert(idx, 0);
}
},
Ramda: {
before: to => {
l = R.range(0, to);
idx = (to / 2) | 0;
},
run: () => {
const l1 = R.insert(idx, 0, l);
}
}
}
);