Skip to content

Commit

Permalink
chore: rework benchmark for multi-mode comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Aug 14, 2020
1 parent 1a85948 commit 46cc9ed
Show file tree
Hide file tree
Showing 10 changed files with 519 additions and 42 deletions.
30 changes: 30 additions & 0 deletions bench/fixtures/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Test {
constructor(num = 123) {
this.value = num;
this.items = [1, 2, 3];
}
get number() {
return this.value;
}
}

module.exports = {
regexp: /foo[\\\/](?=\d)/,
array: [
new Date(),
new Date(100),
'invalid date',
Date.now(),
],
map: new Map([
[{ foo: 1 }, { a: 1 }],
[{ bar: 2 }, { b: 2 }],
]),
set: new Set([
{ foo: 1 }, { bar: 2 }, [1, 2, 3]
]),
custom: new Test(456),
int8arr: new Int8Array([4, 5, 6]),
dataview: new DataView(new ArrayBuffer(4)),
buffer: Buffer.from('hello'),
}
44 changes: 44 additions & 0 deletions bench/fixtures/full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const symbol1 = Symbol('foo');
const symbol2 = Symbol('bar');

const item = {
regexp: /foo[\\\/](?=\d)/,
array: [
new Date(),
new Date(100),
'invalid date',
Date.now(),
],
map: new Map([
[{ foo: 1 }, { a: 1 }],
[{ bar: 2 }, { b: 2 }],
]),
set: new Set([
{ foo: 1 }, { bar: 2 }, [1, 2, 3]
]),
int8arr: new Int8Array([4, 5, 6]),
buffer: Buffer.from('hello'),
symbol1: symbol1,
symbol2: symbol2,
[symbol1]: 'hello',
[symbol2]: [1, 2, 3, 4]
}

Object.defineProperty(item, 'hidden1', {
enumerable: false,
value: 'found me'
});

Object.defineProperty(item, 'hidden2', {
enumerable: false,
value: [1, 2, 3]
});

Object.defineProperty(item, 'secret', {
enumerable: false,
get() {
return 'password';
}
});

module.exports = item;
170 changes: 170 additions & 0 deletions bench/fixtures/json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
module.exports = [
{
"_id": "5e16d8c6d7eee2857c907fbe",
"index": 0,
"nickname": null,
"isActive": false,
"balance": 2077.55,
"picture": "http://placehold.it/32x32",
"age": 33,
"details": {
"email": "ericksonphillips@retrotex.com",
"address": {
"street": "554 Lyme Avenue",
"city": "Harborton",
"state": "Texas",
"zipcode": 4945,
"coords": {
"latitude": 61.497735,
"longitude": -38.711066
}
}
},
"interests": [
"amet",
"voluptate",
"sit",
"duis",
"fugiat",
"consectetur",
"amet"
],
"friends": [
{
"id": 0,
"name": "Belinda Chandler",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "George Ayala"
},
{
"id": 1,
"name": "Nadia Nguyen"
}
]
}
},
{
"id": 1,
"name": "Sheena Kidd",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "Kimberly Martinez"
},
{
"id": 1,
"name": "Meadows Fitzpatrick"
}
]
}
},
{
"id": 2,
"name": "Winnie Mccarthy",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "Robbie Dale"
},
{
"id": 1,
"name": "Orr Houston"
}
]
}
}
]
},
{
"_id": "5e16d8c6ed426d1c22bf306b",
"index": 1,
"nickname": null,
"isActive": false,
"balance": 2916.08,
"picture": "http://placehold.it/32x32",
"age": 20,
"details": {
"email": "orrhouston@retrotex.com",
"address": {
"street": "962 McDonald Avenue",
"city": "Lithium",
"state": "West Virginia",
"zipcode": 4536,
"coords": {
"latitude": 83.372808,
"longitude": 150.181923
}
}
},
"interests": [
"eu",
"et",
"dolore",
"sunt",
"elit",
"nulla",
"fugiat"
],
"friends": [
{
"id": 0,
"name": "Hood Washington",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "Hebert Delacruz"
},
{
"id": 1,
"name": "Sharp Rose"
}
]
}
},
{
"id": 1,
"name": "Karla Velasquez",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "Carey Holman"
},
{
"id": 1,
"name": "Baird Short"
}
]
}
},
{
"id": 2,
"name": "Juliet Oneal",
"friends_common": {
"count": 2,
"friends_of_friends": [
{
"id": 0,
"name": "Owens Richards"
},
{
"id": 1,
"name": "Lily Olsen"
}
]
}
}
]
}
]
File renamed without changes.
Loading

0 comments on commit 46cc9ed

Please sign in to comment.