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
(function run () { | |
//2013.09.27 jorge@jorgechamorro.com | |
//Shows that node's timers are borken and often execute out of order | |
console.log('\nBEGIN'); | |
var MAX= 666; | |
var last= 0; | |
var items= 0; | |
var errores= 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
//plistread.js, 2012-12-30 jorge@jorgechamorro.com | |
var plist= require('plist'); | |
var shell= require('child_process').exec; | |
var puts= console.log; | |
//process.argv[0] -> "node" | |
//process.argv[1] -> "plistread.js" | |
//process.argv[2] -> inputFile | |
//process.argv[3..n] -> property list keys |
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
(function buscarVariablesGlobales (dirtySet, cleanSet) { | |
//© 2013-02-19 jorge@jorgechamorro.com | |
dirtySet= document.body.appendChild(document.createElement('iframe')); | |
cleanSet= Object.getOwnPropertyNames(dirtySet.contentWindow); | |
dirtySet.parentNode.removeChild(dirtySet); | |
dirtySet= Object.getOwnPropertyNames(function () { return this }()); | |
return dirtySet.filter(function (v,i,o) { return cleanSet.indexOf(v) < 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
$ node timers.js | |
setInterval(ƒ,1) -> (µs) : | |
[ 1477, | |
1172, | |
1071, | |
1084, | |
1122, | |
1145, | |
1064, | |
1062, |
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
//2012-09-13 jorge@jorgechamorro.com | |
var ctr, i, t, k= 1e8; | |
function ƒ (i) { ctr+= i } | |
function begin () { i= k, ctr= 0; while (Date.now() === (t= Date.now())) ; } | |
function end (s,t) { console.log(s+ ((Date.now()- t)*1e6/k).toFixed(2)+ 'ns') } | |
begin(); |
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
//2012-06-28 js_vs_c.js | |
var c= 0; | |
var t= Date.now()+1e3; | |
while (c++, (now= Date.now()) < t) ; | |
console.log(c); |
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
//2012-06-28 js_vs_c.c | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/time.h> | |
long long DateNow () { | |
struct timeval time; | |
gettimeofday(&time, NULL); | |
return (long long) ((time.tv_sec* 1000000) + time.tv_usec); |
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
//2012-06-28 functionCall.c jorge@jorgechamorro.com | |
/* | |
$ gcc -O0 /Users/jorge/Desktop/functionCall.c | |
$ ./a.out | |
without a function call: 2.789478 ns per iteration | |
with a function call : 3.574004 ns per iteration | |
With the function call it's 28.124473 percent slower than without the function call | |
*/ |
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
unibody:node-threads-a-gogo jorge$ which node | |
/Users/jorge/JAVASCRIPT/binarios/bin/node | |
unibody:node-threads-a-gogo jorge$ node -v | |
v0.6.17 | |
unibody:node-threads-a-gogo jorge$ node -e 'console.log(process.versions)' | |
{ node: '0.6.17', | |
v8: '3.6.6.25', | |
ares: '1.7.5-DEV', | |
uv: '0.6', | |
openssl: '0.9.8l' } |
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
// 2012-05-19 jorge@jorgechamorro.com | |
var o; | |
function boot () { | |
o= {}; | |
var i= 7e6; | |
while (i--) { | |
var key= i.toString(36); | |
o[key]= { id:key }; | |
} |