Skip to content

Instantly share code, notes, and snippets.

@FbN
Created November 1, 2019 13:06
Show Gist options
  • Save FbN/d8669ab01c1225f239eeafe3d4e2a28a to your computer and use it in GitHub Desktop.
Save FbN/d8669ab01c1225f239eeafe3d4e2a28a to your computer and use it in GitHub Desktop.
import { induce as mostInduce } from '../most.mjs'
import { induce as xstreamInduce } from '../xstream.mjs'
import { induce as rxjsInduce } from '../rxjs.mjs'
import { induce as imperativeInduce } from '../imperative.mjs'
import { typeWriter } from './common.mjs'
import memwatch from '@HolgerFrank/node-memwatch'
const type = process.argv[2]
const cycles = parseInt(process.argv[3])
const induce = {
imperative: imperativeInduce,
most: mostInduce,
xstream: xstreamInduce,
rxjs: rxjsInduce
}
const writer = typeWriter('recursive-' + type)
let queue = Promise.resolve()
function cycle (induce, x) {
x > 0 &&
induce({
resolve: function () {
global.gc()
cycle(induce, x - 1)
}
})
}
memwatch.on('stats', function (info) {
queue = queue.then(() => writer.writeRecords([info]))
})
global.gc()
cycle(induce[type], cycles)
global.gc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment