Skip to content

Instantly share code, notes, and snippets.

@Qard
Created July 16, 2013 02:45
Show Gist options
  • Save Qard/3576fdeef733dcc23c4f to your computer and use it in GitHub Desktop.
Save Qard/3576fdeef733dcc23c4f to your computer and use it in GitHub Desktop.
var profile = require('nodefly-v8-profiler')
, _ = require('underscore')
, util = require('util')
, fs = require('fs')
profile.startProfiling('test')
var express = require('express')
, request = require('request')
, app = express()
app.get('/', function (req, res) {
res.send('Hello, World!')
})
app.listen(3000, '127.0.0.1', function () {
request('http://localhost:3000/', arguments.callee)
})
setTimeout(function () {
var prof = profile.stopProfiling('test')
function populateChildren (source, dest) {
_(_.keys(source)).each(function (key) {
dest[key] = source[key]
})
dest.scriptName = dest.scriptName.replace(result.rootPath, '')
if (source.childrenCount) {
dest.children = []
for (var i = 0; i < source.childrenCount; i++) {
var child = source.getChild(i)
, newChild = _.clone(child)
populateChildren(child, newChild)
dest.children.push(newChild)
}
}
}
var result = _.clone(prof.topRoot)
result.rootPath = __dirname
populateChildren(prof.topRoot, result)
console.log(JSON.stringify(result, null, 2))
process.exit(1)
}, 5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment