-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathslice.perf.ts
More file actions
62 lines (58 loc) · 1.23 KB
/
slice.perf.ts
File metadata and controls
62 lines (58 loc) · 1.23 KB
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
import { benchmark } from "./report";
import * as Immutable from "immutable";
import * as R from "ramda";
import * as L from "../../dist/index";
import * as Lo from "./list-old/dist/index";
let start = 0;
let end = 0;
let l;
let lOld;
benchmark(
{
name: "slice",
description: "Slice 25% off of both ends of a sequence.",
input: [10, 50, 100, 250, 500, 1000, 5000, 10000]
},
{
List: {
before: to => {
l = L.range(0, to);
start = (to / 4) | 0;
end = start * 3;
},
run: () => {
const l1 = L.slice(start, end, l);
}
},
"List, old": {
before: to => {
l = Lo.range(0, to);
start = (to / 4) | 0;
end = start * 3;
},
run: () => {
const l1 = Lo.slice(start, end, l);
}
},
"Immutable.js": {
before: to => {
l = Immutable.Range(0, to).toList();
start = (to / 4) | 0;
end = start * 3;
},
run: () => {
const l1 = l.slice(start, end);
}
},
"Array#slice": {
before: to => {
l = R.range(0, to);
start = (to / 4) | 0;
end = start * 3;
},
run: () => {
const l1 = l.slice(start, end);
}
}
}
);