-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark.ts
65 lines (58 loc) · 1.33 KB
/
benchmark.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
import { Suite } from "benchmark";
import paramsEqual from "./src/paramsEqual";
const time1 = new Date();
const time2 = new Date(12543745);
const log: any[] = [];
const setterGetter = {
log,
set yo(name: string) {
this.log.push(name);
},
get yo() {
return "this is set";
}
};
const onlyGetter = {
log,
get yo() {
return "this is set";
}
};
/* tslint:disable */
const targets: any[] = [
[NaN, NaN],
[true, true],
["", ""],
[2, 2],
[undefined, undefined],
[null, null],
[new Boolean(true), new Boolean(true)],
[new String("true"), new String("true")],
[new Object(), new Object()],
[false, new Boolean(false)],
[[], []],
[[""], []],
[[function() {}], [function() {}]],
[{}, []],
[[{ hi: "hello" }], { hi: "hello" }],
[function() {}, function() {}],
[function hi() {}, function() {}],
[function() {}, () => {}],
[time1, time2],
[{}, { hi: "hello" }],
[{ hi: {} }, { hi: { hello: "hi" } }],
[{ hi: { hello: 1 } }, { hi: { hello: "1" } }],
[onlyGetter, setterGetter],
[setterGetter, setterGetter]
];
targets.forEach((target) => {
console.log("\n", target[0], ",", target[1]);
new Suite()
.add("paramsEqual", () => {
paramsEqual(target[0], target[1]);
})
.on("cycle", (event: Event) => {
console.log(`${String(event.target)}`);
})
.run();
});