More detailed benchmark results from my pc: For understanding obj1..4 and approaches' code please check the benchmark source: https://github.com/AlexeyKupershtokh/node-v8-clone/blob/master/bench/bench.js
obj1 regular cloner x 805,356 ops/sec ±0.69% (94 runs sampled) obj1 regular own cloner x 608,204 ops/sec ±1.16% (93 runs sampled) obj1 static cloner x 57,421,597 ops/sec ±3.64% (78 runs sampled) obj1 node-v8-clone cloner x 6,507,111 ops/sec ±0.83% (88 runs sampled) obj2 regular cloner x 491,173 ops/sec ±1.84% (88 runs sampled) obj2 regular own cloner x 371,417 ops/sec ±3.62% (88 runs sampled) obj2 static cloner x 2,029,810 ops/sec ±0.69% (96 runs sampled) obj2 node-v8-clone cloner x 5,310,824 ops/sec ±0.77% (91 runs sampled) obj3 regular cloner x 1,646 ops/sec ±0.67% (93 runs sampled) obj3 regular own cloner x 973 ops/sec ±0.52% (94 runs sampled) obj3 static cloner x 66,711 ops/sec ±6.26% (91 runs sampled) obj3 node-v8-clone cloner x 42,471 ops/sec ±0.57% (99 runs sampled) obj4 regular cloner x 4,692 ops/sec ±0.65% (92 runs sampled) obj4 regular own cloner x 2,738 ops/sec ±0.68% (92 runs sampled) obj4 static cloner x 11,882 ops/sec ±1.44% (85 runs sampled) obj4 node-v8-clone cloner x 402,496 ops/sec ±0.61% (95 runs sampled) Static cloner is inspired by this video: http://www.youtube.com/watch?feature=player_detailpage&v=Kdwwvps4J9A#t=1000s and is not very applicable IRL. четверг, 22 ноября 2012 г., 18:05:18 UTC+7 пользователь Alexey Kupershtokh написал: > > I see that almost every framework (underscore, lodash, moo, etc) creates > its own clone function. > But v8 engine already has it. > So I've created a module that exposes v8's clone function. Just as a proof > of concept. It needs assertions and currently fails with a segmentation > fault on inputs like null values. > > https://github.com/AlexeyKupershtokh/node-v8-clone > > According to the benchmarks it's: > 8x faster (50x on 1000-key obj) than this approach: > var result = {}; for (i in obj) result[i] = obj[i]; > 12x faster (450x on 1000-key object) than this approach: > var result = {}; for (i in obj) if (obj.hasOwnProperty(i)) result[i] = > obj[i]; > > So I wonder if the community needs this module. > Also node's core developers are welcome to criticize. Is it ok to expose > this function? What are possible drawbacks? Or maybe it's worth to include > this into the node.js core? > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
