Or, assuming you’re using Node 0.8 or newer (which you should be):
var start = process.hrtime();
makeSoapCall(function (err) {
var duration = process.hrtime(start);
console.error("SOAP call took %s milliseconds", (duration[0] * 1e9 + duration[1]) / 1e6);
});
In general, process.hrtime() will be much more accurate than new Date(). If you want aggregated metrics for your HTTP / SOAP calls over time, look at metrics-gathering agent like New Relic, AppDynamics / Nodetime, or StrongLoop’s StrongOps. You could write all the code yourself, but as someone who’s done it, it’s kind of a pain to do yourself, even if the results are much more useful than a list of request times printed to stderr / stdout.
F