/node-instances-benchmarks

Just a performance test related to what method is faster than the others

Primary LanguageJavaScript

Node instances benchmarks

Which is the faster method to declare 1 million of objects instances in a simple array?

The methods used in this test are:

  • Factory method using function with arguments and closures, see this link for more informations
  • Prototype method using prototype inheritance, as the same as Javascript does for methods like push for arrays, see this link for more informations
  • Class method using the keyword class that creates a special function, see this link for more informations
  • Factory method with Object.assign + Object.create, another method but similar to the first but different in terms of performance, see this link for more informations

This is the result of these benchmarks in the terminal:

benchmark on terminal


This is the representation of the same data in a column chart, just to display better the comparison

benchmark on terminal


The winners in terms of performance are the class method and the prototype method that have the same performance