node dnsLagDnsServer.js
node dnsLagServer.js
node dnsLag.js
--- dnsLag.js should timeout if the timeout was affected
// in api | |
var buildUrl = miscLib.memoizeSync(function(args) { | |
return crmLib.buildMultipleDetailUrl({ | |
title : args.title, | |
recid : args.recid, | |
defaultPath : plugin._def.settings.detail.path, | |
detailPath : miscLib.varLookup(plugin._detailTypeIndexBySite, [args.detail_type, args.site]), | |
sitePath : miscLib.varLookup(site, ["siteConfigs", args.site, "urlNoSlash"]), | |
absolute : args.absolute | |
}); |
var dns = require("dns"); | |
var http = require("http"); | |
var fs = require("fs"); | |
var net = require("net"); | |
dns.setServers(["127.0.0.1"]); | |
var makeCallLookup = function(cb) { | |
dns.lookup("testSlow.com", cb); | |
} |
// var fs = require("fs"); | |
// var Module = require("module"); | |
// var pathCache = JSON.parse(fs.readFileSync("/sv/test/pathCache.json").toString()); | |
// Object.keys(pathCache).forEach(function(val, i) { | |
// Module._pathCache[val] = pathCache[val]; | |
// }); | |
// console.time("load"); | |
// // var mongolayer = require("/sv/node_modules/npm/mongolayer/1/node_modules/mongolayer/"); |
node dnsLagDnsServer.js
node dnsLagServer.js
node dnsLag.js
--- dnsLag.js should timeout if the timeout was affected
------------ | |
test { populationSize: 100000000, | |
sampleSize: 1000, | |
bias: 50, | |
marginOfError: 0.030990321069650117 } | |
inMarginOfError { yes: 940, no: 60 } | |
predictedElections { wins: 513, ties: 34, losses: 453 } | |
------------ | |
test { populationSize: 100000000, | |
sampleSize: 1000, |
In the following test code there are two things to look for.
"in cb 0 0 1" means that it is in the callback after the call to mongodb, and the numbers are "expectedNum actualNum stackSize". The expectedNum and actualNum match, and they do. The stackSize should always be 1. In the event the stackSize is not 1 it means that the domains are not being properly entered and exited. If the stackSize grows domains are leaking.
Another important marker is the "after exit" and "end call" blocks, they should always be undefined. In the event that they are not undefined it means that a domain is lingering after exit, which results in subsequent code being in a domain it shouldn't, as well as a possible memory leak.
From the test file it appears that both setImmediate and process.nextTick() work.
var async = require("async/"); | |
var mongodb = require("mongodb"); | |
var assert = require("assert"); | |
mongodb.MongoClient.connect("mongodb://127.0.0.1/test", {}, function(err, conn) { | |
if (err) { throw err; } | |
var collection = conn.collection("test"); | |
var newDocs = []; |
npm: 34ms | |
json: 7ms | |
317780 307781 |
foo
foo
foo
Example showing async.waterfall
which functions semantically the same as promises.
<script src="http://cdnjs.cloudflare.com/ajax/libs/async/1.22/async.min.js"></script>
<script>
// waterfall wrapper to try/catch each method in a waterfall
var catchWaterfall = function(arr, cb) {
var calls = [];
arr.forEach(function(val) {