20180710

BlackScript

Valuable technique in JavaScript class coding: link

The following benchmarks indicate a performance improvement for bulk object creation.
Try this in your own browser here

Update 20230119: Ex Nihilo wins in jsbench.me tests on Chrome 109 and Firefox 109:

Chrome 109

Firefox 109



Older benchmarks follow for archival reference:

A benchmark.js test running on node.js:
________________________________________________________
Research>node --version
v10.16.3

Research>node bench.js
OldStyleClass x 165,772 ops/sec ±0.38% (106 runs sampled)
Ex Nihilo x 180,305 ops/sec ±0.50% (104 runs sampled)
Fastest is Ex Nihilo

Research>node bench.js
NewStyleClass x 163,242 ops/sec ±0.28% (111 runs sampled)
Ex Nihilo x 180,219 ops/sec ±0.46% (100 runs sampled)
Fastest is Ex Nihilo

Research>node bench.js
OldStyleClass x 160,930 ops/sec ±0.58% (103 runs sampled)
NewStyleClass x 161,634 ops/sec ±0.79% (105 runs sampled)
Ex Nihilo x 176,387 ops/sec ±0.44% (107 runs sampled)
Fastest is Ex Nihilo

Older runs on jsperf.com:




Update 20200627: None of the newer versions of the browsers run Ex Nihilo faster. Optimization wins!

Update 20201006: Additional server-side tests:
________________________________________________________
Research>node --version
v12.19.0

Research>node bench.js
OldStyleClass x 153,207 ops/sec ±0.95% (84 runs sampled)
NewStyleClass x 150,535 ops/sec ±0.32% (93 runs sampled)
Ex Nihilo x 166,850 ops/sec ±1.84% (91 runs sampled)
Fastest is Ex Nihilo

________________________________________________________
Research>node --version
v13.14.0

Research>node bench.js
OldStyleClass x 151,339 ops/sec ±0.76% (86 runs sampled)
NewStyleClass x 147,369 ops/sec ±0.27% (95 runs sampled)
Ex Nihilo x 164,624 ops/sec ±0.26% (93 runs sampled)
Fastest is Ex Nihilo

________________________________________________________
Research>node --version
v14.13.0

Research>node bench.js
OldStyleClass x 147,954 ops/sec ±1.03% (87 runs sampled)
NewStyleClass x 144,716 ops/sec ±0.37% (93 runs sampled)
Ex Nihilo x 160,388 ops/sec ±0.47% (89 runs sampled)
Fastest is Ex Nihilo

KVR News:

The Gadget Blog | Latest Gadgets, Technology