Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-04-27 22:29:35 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-04-27 22:38:58 +0400
commit4e84dfa6830336131a63993dcf2119b3edcb0f37 (patch)
treee5774544d9648d04b3a63da82f423a63121e5ff5 /benchmark
parent70635753a3ff982ddb8686ecbb6b73b4780f8721 (diff)
bench: run GC and dump stats if --expose-gc is set
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http_simple_auto.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/benchmark/http_simple_auto.js b/benchmark/http_simple_auto.js
index 4e136a67eae..31926351fb1 100644
--- a/benchmark/http_simple_auto.js
+++ b/benchmark/http_simple_auto.js
@@ -105,5 +105,24 @@ server.listen(port, function () {
cp.stderr.pipe(process.stderr);
cp.on('exit', function() {
server.close();
+ process.nextTick(dump_mm_stats);
});
});
+
+function dump_mm_stats() {
+ if (typeof gc != 'function') return;
+
+ var before = process.memoryUsage();
+ for (var i = 0; i < 10; ++i) gc();
+ var after = process.memoryUsage();
+ setTimeout(print_stats, 250); // give GC time to settle
+
+ function print_stats() {
+ console.log('\nBEFORE / AFTER GC');
+ ['rss', 'heapTotal', 'heapUsed'].forEach(function(key) {
+ var a = before[key] / (1024 * 1024);
+ var b = after[key] / (1024 * 1024);
+ console.log('%sM / %sM %s', a.toFixed(2), b.toFixed(2), key);
+ });
+ }
+}