Created
August 1, 2018 08:25
-
-
Save YassineBajdou/6f69e6d4d1dd9e2a273295de46a2b59c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
class Person { | |
constructor({ | |
firstname = '', | |
lastname = '', | |
spaceship = '', | |
job = '', | |
gender = '', | |
retired = false | |
} = {}) { | |
Object.assign(this, { | |
firstname, | |
lastname, | |
spaceship, | |
job, | |
gender, | |
retired | |
}); | |
} | |
} | |
const han = new Person({ | |
firstname: 'Han', | |
lastname: 'Solo', | |
spaceship: 'Falcon' | |
}); | |
const luke = new Person({ | |
firstname: 'Luke', | |
lastname: 'Skywalker', | |
job: 'Jedi' | |
}); | |
const leia = new Person({ | |
firstname: 'Leia', | |
lastname: 'Organa', | |
gender: 'female' | |
}); | |
const obi = new Person({ | |
firstname: 'Obi', | |
lastname: 'Wan', | |
retired: true | |
}); | |
const yoda = new Person({ lastname: 'Yoda' }); | |
const people = [ | |
han, | |
luke, | |
leia, | |
obi, | |
yoda, | |
luke, | |
leia, | |
obi | |
]; | |
const getName = person => person.lastname; | |
console.time('engine'); | |
for (var i = 0; i < 1000 * 1000 * 1000; i++) { | |
getName(people[i & 7]); | |
} | |
console.timeEnd('engine'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment