This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum ValueType | |
{ | |
NULL, | |
UNDEFINED, | |
NUMBER_INT, | |
NUMBER_DOUBLE, | |
STRING, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This test detects if engine cache bytecode or not. | |
*/ | |
var _main = function() | |
{ | |
var bigCode = String(_main); | |
bigCode = bigCode.slice(bigCode.indexOf('{') + 1, bigCode.lastIndexOf('}')); | |
bigCode = new Array(11).join(bigCode); // *= 10 to make really big code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://en.wikipedia.org/wiki/Fast_inverse_square_root | |
/* | |
Discovering old well known algorithm speed in js. | |
*/ | |
/* | |
Update 1 | |
Added 3rd variant - 1st with removed <y> varable. Hm, it really become more faster. Thanks Andrea! | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Strong implementation must check that key is object, | |
hide weakMapN_ from enumeration, make it externally readonly and non deletable(Object.defineProperty, if presents), | |
but its bad for performance. | |
*/ | |
(function($G) | |
{ | |
var nextStoreKeyId = 0; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
es5 introduces new Object api. Object.keys returns array of own enumerable keys of object. | |
In es3 we have classic construction "for in hasOwnProperty" for this purposes. | |
Test try to find what is best - es3 enumeration or es5 | |
In es5 we have overhead of array making and allocation | |
In es3 we have overhead of enumeration extra properties from prototype chain and filter it(using hasOwnProperty - extra function call) | |
update 1 | |
according brilliant idea of @abozhilov (http://twitter.com/abozhilov/status/26758011447) there is 3rd way which | |
uses nonstandard __proto__ (presents in v8 and JagerMonkey) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$jb._isFunction([].map) && | |
(function(){ | |
var n = 0 | |
, isFail = false | |
, a = [1, 2, 3] | |
, b = a.map( | |
function(v, i, vs) | |
{ | |
n |= 1 << i; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype._shuffleSelf = function() | |
{ | |
var i = this.length; | |
if(i >= 2) | |
{ | |
var _rand = Math.random; | |
while(--i) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// via me and @kangax | |
(function() | |
{ | |
var a = {}; | |
var someId = new Date(); | |
var proto = {}; | |
proto[someId] = someId; | |
return (a.__proto__ = proto, a[someId] === someId) && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright 2006 Emil A Eklund <[email protected]> & Erik Arvidsson <[email protected]> | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
this test shows independence loop structure of performance | |
internal asm code become same | |
*/ | |
var m = 1000 | |
, aL = new Array(m) | |
; | |
aL[aL.length - 1] = 1; |