Skip to content

Instantly share code, notes, and snippets.

View papandreou's full-sized avatar
💭
🤗

Andreas Lind papandreou

💭
🤗
View GitHub Profile
var fs = require('fs'),
step = require('step'),
jsdom = require('jsdom'),
window = jsdom.createWindow(),
Script = process.binding('evals').Script;
window.document = {};
window.Ext = {data:{Record:{}}};
var fileNames = [
var one = {}
, two = {'o':true}
;
function ifTest () {
var start = new Date();
var i = 0;
while (i<10000) {
if (one.o) true
if (two.o) true
#
# Fatal error in /home/node4/work/node/deps/v8/src/heap.h, line 1557
# CHECK(Page::FromAddress(addr)->IsRegionDirty(addr)) failed
#
==== Stack trace ============================================
Security context: 0xb4fbebe9 <JS Object>#0#
1: _registerBaseAssetPath [/home/node4/work/assetgraph/lib/AssetGraph.js:~350] (this=0xb65bdc31 <an AssetGraph>>#1#,relation=0xb4db66d9 <an HTMLScript>>#2#)
var seq = require('seq'),
obj = {};
for (var i = 0 ; i < 10000 ; i += 1) {
var otherObj = {foo: obj};
obj['foo' + i] = otherObj
}
seq([obj])
.parEach(function (obj) {
@papandreou
papandreou / gist:1120060
Created August 2, 2011 12:00
new Object vs. {} benchmark
function benchmark() { // ...
for (var i = 0 ; i < arguments.length ; i += 1) {
var startTime = new Date(),
fn = arguments[i];
for (var j = 0 ; j < 10000000 ; j += 1) {
fn();
}
console.warn(arguments[i].name + ": " + ((new Date().getTime() - startTime) / 1000).toFixed(3));
}
}
@papandreou
papandreou / bench.js
Created February 17, 2012 22:49
Benchmark of different ways of matching /@(-(?:[a-z]+-)+)?keyframes/ against a specific position in a string
var testCases = [
{
input: new Array(4001).join('0123456789') + '@-webkit-keyframes {}' + new Array(4096).join('0123456789'),
idx: 40000
},
{
input: new Array(4001).join('0123456789') + '@keyframes {}' + new Array(4096).join('0123456789'),
idx: 40000
},
{
@papandreou
papandreou / after
Created July 12, 2012 08:30
Output of jsdom test suite before and after applying 1bf9682 and cefc3f6 to jsdom master (73ce351)
running level1/core.js level1/core
running level1/html.js level1/html
running level1/svg.js level1/svg
running level2/core.js level2/core
running level2/html.js level2/html
running level2/style.js level2/style
running level2/extra.js level2/extra
running level2/events.js level2/events
running level3/xpath.js level3/xpath
running window/index.js window/index
@papandreou
papandreou / observable.js
Last active September 11, 2015 15:15
Stripped down version of ko.observable with all the prototype trickery
function setPrototypeOf(obj, proto) {
obj.__proto__ = proto;
return obj;
}
var canSetPrototype = ({ __proto__: [] } instanceof Array);
var setPrototypeOfOrExtend = canSetPrototype ? setPrototypeOf : function extend(target, source) {
if (source) {
for (var prop in source) {
#!/usr/bin/env node
/*global JSON*/
var childProcess = require('child_process');
var async = require('async');
var passError = require('passerror');
var commandLineOptions = require('optimist').demand(1).argv;
var results = [];
var refs = commandLineOptions._;
function parseType(str) {
return str.split('|').map(function (typeDeclaration) {
var varargs = /^\.\.\./.test(typeDeclaration);
if (varargs) {
return { varargs: typeDeclaration.substr(3) };
} else {
return typeDeclaration;
}
});
}