Skip to content

Instantly share code, notes, and snippets.

// cache from global scope
var _parseInt = this.parseInt;
_speedTest(
[
function(n)
{
var r, g, b, s = '#aabbcc';
var i = n; while(i--)
{
var _abs = Math.abs;
_speedTest(
[
function(n)
{
var a = 0;
var i = n; while(i--)
{
var _abs = Math.abs;
var _floor = Math.floor;
var _rand = Math.random;
_speedTest(
[
function(n)
{
var i = n; while(i--)
this.$jb.Loader._scope().
_require('$jb/$G.Function.js').
_require('$jb/OOP.js').
_require('http.node').
_require('$jb/exceptions.js').
_require('$jb/$jb.Url.js').
_require('$jb/$jb.Net.Base.js').
_willDeclared('$jb/$jb.Net.HTTPClient.js').
_completed(function($G, $jb){
(function($G)
{
var cache = {};
var XHR = $G.XMLHttpRequest || function(){ return new $G.ActiveXObject('Microsoft.XMLHTTP') };
$G.require = function(url)
{
if(!(url in cache))
{
var xhr = new XHR();
/**
@hint
@see https://wiki.mozilla.org/Audio_Data_API
@see http://www.opensource.apple.com/source/WebCore/WebCore-737.5/html/canvas/
@see https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html
Array.U32 = $G.Uint32Array || $G.WebGLUnsignedIntArray || $G.CanvasUnsignedIntArray || Array;
Array.U16 = $G.Uint16Array || $G.WebGLUnsignedShortArray || $G.CanvasUnsignedShortArray || Array;
Array.U8 = $G.Uint8Array || $G.WebGLUnsignedByteArray || $G.CanvasUnsignedByteArray || Array;
/*
Basic idea - measure cost of simplest operation of js in cpu cycles
asm
//var i = n;
mov EAX, n
// while(i--);
a: dec EAX
/*
Goal of this test is find best data structure for store matrices, vectors and quaternions
In C/C++ we have ability to store same data different ways ie
union
{
float m[9];
struct
{
float
m00, m01, m02
/*
Traditionally in js we separate arrays and hashes(maps, Object, dictionary, ...)
Test shows that modern engines havent array optimization - it just hash with automatic <.length> property and sugar array like methods :(
*/
var m = 1000;
var _fill = function(a)
{
"use strict";
(function()
{
var _warmUp = function()
{
var d = Date.now();
while(Date.now() - d < 4000)
{