const testToRun = 1000;
const prototypeTimes = [];
const classTimes = [];
let start = 0;
let end = 0;
PrototypeTest.prototype = {
initialize: function(){},
testOne: function(){ console.log("this is test 1.") },
testTwo: function(){ console.log("this is test 2.") },
testThree: function(){ console.log("this is test 3.") },
testFour: function(){ console.log("this is test 4.") },
testFive: function(){ console.log("this is test 5.") },
testSix: function(){ console.log("this is test 6.") },
testSeven: function(){ console.log("this is test 7.") },
testEight: function(){ console.log("this is test 8.") },
testNine: function(){ console.log("this is test 9.") },
testTen: function(){ console.log("this is test 10.") }
}
function PrototypeTest(id){
this.id = id;
this.initialize()
}
class ClassTest{
constructor(id){
this.id = id;
}
testOne = () => { console.log("this is test 1.") }
testTwo = () => { console.log("this is test 2.") }
testThree = () => { console.log("this is test 3.") }
testFour = () => { console.log("this is test 4.") }
testFive = () => { console.log("this is test 5.") }
testSix = () => { console.log("this is test 6.") }
testSeven = () => { console.log("this is test 7.") }
testEight = () => { console.log("this is test 8.") }
testNine = () => { console.log("this is test 9.") }
testTen = () => { console.log("this is test 10.") }
}
console.log("Starting Prototype")
for(let i = 0; i < testToRun; i++){
start = Date.now();
new PrototypeTest(i)
end = Date.now();
prototypeTimes.push( end - start )
}
console.log("Ending Prototype")
console.log("Starting Class")
for(let i = 0; i < testToRun; i++){
start = Date.now();
new ClassTest(i)
end = Date.now();
classTimes.push( end - start )
}
console.log("Ending Class")
console.log(prototypeTimes)
console.log(classTimes)
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.