Skip to content

Commit 46cc9ed

Browse files
committed
chore: rework benchmark for multi-mode comparisons
1 parent 1a85948 commit 46cc9ed

File tree

10 files changed

+519
-42
lines changed

10 files changed

+519
-42
lines changed

Diff for: bench/fixtures/default.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class Test {
2+
constructor(num = 123) {
3+
this.value = num;
4+
this.items = [1, 2, 3];
5+
}
6+
get number() {
7+
return this.value;
8+
}
9+
}
10+
11+
module.exports = {
12+
regexp: /foo[\\\/](?=\d)/,
13+
array: [
14+
new Date(),
15+
new Date(100),
16+
'invalid date',
17+
Date.now(),
18+
],
19+
map: new Map([
20+
[{ foo: 1 }, { a: 1 }],
21+
[{ bar: 2 }, { b: 2 }],
22+
]),
23+
set: new Set([
24+
{ foo: 1 }, { bar: 2 }, [1, 2, 3]
25+
]),
26+
custom: new Test(456),
27+
int8arr: new Int8Array([4, 5, 6]),
28+
dataview: new DataView(new ArrayBuffer(4)),
29+
buffer: Buffer.from('hello'),
30+
}

Diff for: bench/fixtures/full.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const symbol1 = Symbol('foo');
2+
const symbol2 = Symbol('bar');
3+
4+
const item = {
5+
regexp: /foo[\\\/](?=\d)/,
6+
array: [
7+
new Date(),
8+
new Date(100),
9+
'invalid date',
10+
Date.now(),
11+
],
12+
map: new Map([
13+
[{ foo: 1 }, { a: 1 }],
14+
[{ bar: 2 }, { b: 2 }],
15+
]),
16+
set: new Set([
17+
{ foo: 1 }, { bar: 2 }, [1, 2, 3]
18+
]),
19+
int8arr: new Int8Array([4, 5, 6]),
20+
buffer: Buffer.from('hello'),
21+
symbol1: symbol1,
22+
symbol2: symbol2,
23+
[symbol1]: 'hello',
24+
[symbol2]: [1, 2, 3, 4]
25+
}
26+
27+
Object.defineProperty(item, 'hidden1', {
28+
enumerable: false,
29+
value: 'found me'
30+
});
31+
32+
Object.defineProperty(item, 'hidden2', {
33+
enumerable: false,
34+
value: [1, 2, 3]
35+
});
36+
37+
Object.defineProperty(item, 'secret', {
38+
enumerable: false,
39+
get() {
40+
return 'password';
41+
}
42+
});
43+
44+
module.exports = item;

Diff for: bench/fixtures/json.js

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
module.exports = [
2+
{
3+
"_id": "5e16d8c6d7eee2857c907fbe",
4+
"index": 0,
5+
"nickname": null,
6+
"isActive": false,
7+
"balance": 2077.55,
8+
"picture": "http://placehold.it/32x32",
9+
"age": 33,
10+
"details": {
11+
"email": "[email protected]",
12+
"address": {
13+
"street": "554 Lyme Avenue",
14+
"city": "Harborton",
15+
"state": "Texas",
16+
"zipcode": 4945,
17+
"coords": {
18+
"latitude": 61.497735,
19+
"longitude": -38.711066
20+
}
21+
}
22+
},
23+
"interests": [
24+
"amet",
25+
"voluptate",
26+
"sit",
27+
"duis",
28+
"fugiat",
29+
"consectetur",
30+
"amet"
31+
],
32+
"friends": [
33+
{
34+
"id": 0,
35+
"name": "Belinda Chandler",
36+
"friends_common": {
37+
"count": 2,
38+
"friends_of_friends": [
39+
{
40+
"id": 0,
41+
"name": "George Ayala"
42+
},
43+
{
44+
"id": 1,
45+
"name": "Nadia Nguyen"
46+
}
47+
]
48+
}
49+
},
50+
{
51+
"id": 1,
52+
"name": "Sheena Kidd",
53+
"friends_common": {
54+
"count": 2,
55+
"friends_of_friends": [
56+
{
57+
"id": 0,
58+
"name": "Kimberly Martinez"
59+
},
60+
{
61+
"id": 1,
62+
"name": "Meadows Fitzpatrick"
63+
}
64+
]
65+
}
66+
},
67+
{
68+
"id": 2,
69+
"name": "Winnie Mccarthy",
70+
"friends_common": {
71+
"count": 2,
72+
"friends_of_friends": [
73+
{
74+
"id": 0,
75+
"name": "Robbie Dale"
76+
},
77+
{
78+
"id": 1,
79+
"name": "Orr Houston"
80+
}
81+
]
82+
}
83+
}
84+
]
85+
},
86+
{
87+
"_id": "5e16d8c6ed426d1c22bf306b",
88+
"index": 1,
89+
"nickname": null,
90+
"isActive": false,
91+
"balance": 2916.08,
92+
"picture": "http://placehold.it/32x32",
93+
"age": 20,
94+
"details": {
95+
"email": "[email protected]",
96+
"address": {
97+
"street": "962 McDonald Avenue",
98+
"city": "Lithium",
99+
"state": "West Virginia",
100+
"zipcode": 4536,
101+
"coords": {
102+
"latitude": 83.372808,
103+
"longitude": 150.181923
104+
}
105+
}
106+
},
107+
"interests": [
108+
"eu",
109+
"et",
110+
"dolore",
111+
"sunt",
112+
"elit",
113+
"nulla",
114+
"fugiat"
115+
],
116+
"friends": [
117+
{
118+
"id": 0,
119+
"name": "Hood Washington",
120+
"friends_common": {
121+
"count": 2,
122+
"friends_of_friends": [
123+
{
124+
"id": 0,
125+
"name": "Hebert Delacruz"
126+
},
127+
{
128+
"id": 1,
129+
"name": "Sharp Rose"
130+
}
131+
]
132+
}
133+
},
134+
{
135+
"id": 1,
136+
"name": "Karla Velasquez",
137+
"friends_common": {
138+
"count": 2,
139+
"friends_of_friends": [
140+
{
141+
"id": 0,
142+
"name": "Carey Holman"
143+
},
144+
{
145+
"id": 1,
146+
"name": "Baird Short"
147+
}
148+
]
149+
}
150+
},
151+
{
152+
"id": 2,
153+
"name": "Juliet Oneal",
154+
"friends_common": {
155+
"count": 2,
156+
"friends_of_friends": [
157+
{
158+
"id": 0,
159+
"name": "Owens Richards"
160+
},
161+
{
162+
"id": 1,
163+
"name": "Lily Olsen"
164+
}
165+
]
166+
}
167+
}
168+
]
169+
}
170+
]

Diff for: bench/input.js renamed to bench/fixtures/lite.js

File renamed without changes.

0 commit comments

Comments
 (0)