-
Notifications
You must be signed in to change notification settings - Fork 51
/
iterator.perf.ts
64 lines (61 loc) · 1.24 KB
/
iterator.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
import { benchmark } from "./report";
import * as R from "ramda";
import * as L from "../../dist/index";
import * as Lo from "./list-old/dist/index";
import * as Immutable from "immutable";
let n = 0;
let l;
let lOld;
let immList;
let array;
benchmark(
{
name: "iterator",
description: "Iterate over a sequence with a for-of loop.",
input: [10, 50, 100, 250, 500, 1000, 5000],
before: n => {
l = L.range(0, n);
lOld = Lo.range(0, n);
immList = Immutable.Range(0, n).toList();
array = R.range(0, n);
}
},
{
List: {
run: () => {
var result = 10000;
for (var cur of l) {
result = result - cur;
}
return result;
}
},
"List, old": {
run: () => {
var result = 10000;
for (var cur of lOld) {
result = result - cur;
}
return result;
}
},
"Immutable.js": {
run: () => {
var result = 10000;
for (var cur of immList) {
result = result - cur;
}
return result;
}
},
Array: {
run: () => {
var result = 10000;
for (var cur of array) {
result = result - cur;
}
return result;
}
}
}
);