Posts

Showing posts with the label objects

JavaScript recent Bits and Bobs

Quick post about few things landed, or not yet, in JavaScript world. preciseTime() In this era loads of +new Date , JSC offers since quite a while a handy global function called preciseTime() . Since this function offers more accuracy than milliseconds, and I am talking about microseconds, which is 1/1000 of a millisecond, it's the best option we have to measure benchmarks or be sure that some time elapsed between two statements in a synchronous code flow. You might don't know that a loop between new Date and another new Date could produce completely unexpected results such a negative integer which is kinda unexpected since zero is the best case we would consider. This behavior is behind ticks and clocks , more or less same reason setTimeout or setInterval have never been accurate in therms of delay. preciseTime , this is the obvious name of my latest git repository, could be shimmed or polyfilled quite easily via a node module I can't npm install for some reason,...

JSONH And Hybrid JS Objects

Image
I have already described JSONH and now I also have the proof that it's as safe as native JSON is but on average 2X faster than native JSON operations with both small (10 objects), medium (100 objects), and massive (5000 objects and not a real world case, just a stress test to see how much JSONH scales) homogenous collections. Wherever it's not faster it's just " as fast " but the best part is that it seems to be always faster on slower machines ( mobile ). Moreover, the 5000 objects stress example shows that JSONH.stringify() produces a string with 54% of original JSON.stringify() size so here the summary: JSONH is faster on both compression and decompression plus it produces smaller output yeah but ... what About Hybrid Objects To start with, if you don't recognize/understand what is an homogenous collection and ask me: " what about nested objects? ", all I can do is to point you out that Peter Michaux explained this years before me. Have a ...