summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js')
-rw-r--r--chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js b/chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js
new file mode 100644
index 00000000000..1a022af3576
--- /dev/null
+++ b/chromium/third_party/catapult/third_party/polymer2/bower_components/async/perf/memory.js
@@ -0,0 +1,46 @@
+if (process.execArgv[0] !== "--expose-gc") {
+ console.error("please run with node --expose-gc");
+ process.exit(1);
+}
+
+var async = require("../");
+global.gc();
+var startMem = process.memoryUsage().heapUsed;
+
+function waterfallTest(cb) {
+ var functions = [];
+
+ for(var i = 0; i < 10000; i++) {
+ functions.push(function leaky(next) {
+ function func1(cb) {return cb(); }
+
+ function func2(callback) {
+ if (true) {
+ callback();
+ //return next(); // Should be callback here.
+ }
+ }
+
+ function func3(cb) {return cb(); }
+
+ async.waterfall([
+ func1,
+ func2,
+ func3
+ ], next);
+ });
+ }
+
+ async.parallel(functions, cb);
+}
+
+function reportMemory() {
+ global.gc();
+ var increase = process.memoryUsage().heapUsed - startMem;
+ console.log("memory increase: " +
+ (+(increase / 1024).toPrecision(3)) + "kB");
+}
+
+waterfallTest(function () {
+ setTimeout(reportMemory, 0);
+});