{"_id":"async-profile","_rev":"39-f66754ac561f2df766d6e560445f9550","name":"async-profile","description":"Node.js async CPU profiler","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"index.coffee","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.1.0","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.1.0","dist":{"shasum":"e5863396b3da48fb98e86fc85855838bf1c41261","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.1.0.tgz","integrity":"sha512-+9CuXGgqXO7EurXfQ6Ws9wSuZudqY71b69aOT7IzicMFFMFF/4TVup6R/8THn994Hq+eD5AnX/NPOvNd7ys4gA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEPmwAr9Y4na6pL2NsPng3D0WRCmEPhPn3EOd5TyiPmOAiAruboaid2HS3ktEmsgSd8GKNX1kL0YGPXX1Go6ytvQmg=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.1.1":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.1.1","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.1.1","dist":{"shasum":"87fddc0a58d5caaa7c6efc93a9351c6ee1787cad","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.1.1.tgz","integrity":"sha512-nRTMOHGnH8xx0G4CwYhjukXvNPOAMMPK9Z7UizdXGhwaweLzRWWH40mJQNKABjB1D24+GFG15EC+bTqrA82bjA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICP65INN3E8zbDYjlzQHUVqeza08bfL0NzuyZYlrqWYtAiAJClrnK6TWc2Dv/JvEFp0s7v+oN/Un7KWrOT48jOxiiw=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.2.0":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.2.0","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.2.0","dist":{"shasum":"9ac385769f6519504d132e4db78bca15c741d2b9","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.2.0.tgz","integrity":"sha512-qchYD6ITJBMqI6wazLiTOOsTPc7wzXbq38iUXBGbf1tgKYbLFRPWknesh9TaxieD19TtO008oI7/J8ofPsXacw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCfeaL6gOscLm9luCWCBhK3NXT+iQ9KQ+a1w0O+BiKVjQIhAMeOOrRWYO/xqGD0mvoO0JzQvTyIhkMMaolGAmBqmquE"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.2.1":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.2.1","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.2.1","dist":{"shasum":"b5087a962e673ff6fcedb6a6e138635a5b5ff0ae","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.2.1.tgz","integrity":"sha512-SPEVBOt2qpUiN/ojMKo0bNcvN3gN+kVgHLRIb9yjAtMWPZU4b/RKVpD/wSQ5Iy1vHUEbpHoiAZXP88B6D85U6w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDQdjrFVXp/Bn2sTiwEn/Hp6BRfIYWfuAzh8tIbP5TatAiBJ2ApicxnYTELtEqAzZjPvzQ04HfJuqrBitOrxCEnTZg=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.2.3":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.2.3","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.2.3","dist":{"shasum":"a146a2403a9a7c38766f2688ebc487786b6470b7","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.2.3.tgz","integrity":"sha512-jVTbi1Xeocrh/s3MayzmtLQHL0djJWLjBKCqdt+YP11flVRd3SUovJWysZgOlYW+A9cVE8zMDPMdszSdOSD+HA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICjXxcCRSDepA5bpzcfUJ4qOTBZzmh0m6GYY/dFi189pAiEA9qYEzspsjk77YHE7ma9eF3GR+wvf1oEjIKaRY+c+61w="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.3.1":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*"},"version":"0.3.1","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.3.1","dist":{"shasum":"58116d9c662c397eadd9eb85a4bad27de21a4f02","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.3.1.tgz","integrity":"sha512-aEMzXs04L5tcuCBgCGSiCJ5hghGYDm1Bwn12Mt7NPpHn3IDRTw1xIIqhRC+HE5KPyCgQIDpirZwZAu9hcXbJuw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAVIoEEexwaw45f6uvk1YeFACSYNTqgpaLfD5MYV6P1AIhAO2sGChS6DDpot6c1ePGppQtlMuBjzqVB+ppvCtkHbyo"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}},"0.4.0":{"dependencies":{"async-listener":"0.4.5"},"description":"Node.js async CPU profiler","devDependencies":{"coffee-script":"latest","mocha":"latest"},"engines":{"node":">=0.8.0"},"homepage":"https://github.com/ConradIrwin/async-profile","licenses":[{"type":"MIT","url":"https://github.com/ConradIrwin/async-profile"}],"main":"lib/index.js","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"name":"async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"scripts":{"prepublish":"coffee -c -o lib src/*","test":"mocha --compilers coffee:coffee-script/register test"},"version":"0.4.0","bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"_id":"async-profile@0.4.0","dist":{"shasum":"d3040d6b33d3248c97687e6e525eabc4de182608","tarball":"https://registry.npmjs.org/async-profile/-/async-profile-0.4.0.tgz","integrity":"sha512-2gOR0AakWlvKhXauGAcnUnFsiZ5mCXpP2id2P8/WXsZEyIb+WSty5b0rP2qZ9PpHqYf8Wjb1hU6OXmlXMHCviA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDnZG47o2o952t4Y62B4oo/M7aSxCXddNbHS0PNQL+uWwIgH9xYOoK6tHfjwNfVpw123JF+i8ZKIVWMnn7C6xUji9k="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"cirwin","email":"conrad.irwin@gmail.com"}}},"readme":"Node async-profile profiles CPU usage in node apps.\n\nIt lets you see at a glance how much CPU time is being taken up by a given part of your app, even if that\npart of your app is also doing asynchronous IO.\n\nI built it at [Bugsnag](https://bugsnag.com) to help us understand why our background processors were\nusing 100% CPU all the time.\n\n# Installation\n\nThis currently only works on node 0.10. 0.11 support should be easy to add, and much lower overhead :).\n\n\n```\nnpm install async-profile\n```\n\n# Usage\n\nWhen you create a new AsyncProfile it automatically profiles work done by any asynchronous callbacks\ncreated in the current 'tick', and then writes the results to stdout.\n\n```javascript\nvar AsyncProfile = require('async-profile')\n\n// First set up an isolated callback (using any function that executes its callback asynchronously).\n// Any callbacks created in this callback will be profiled transitively.\nprocess.nextTick(function () {\n\n    // Now start profiling. The profile will include all\n    // callbacks created while the current callback is running.\n    new AsyncProfile()\n\n    // Finally queue up the work to be done asynchronously.\n    process.nextTick(doWork);\n})\n```\n\n## Interpreting the output\n\nThe output looks something like this: (taken from a profile of [bugsnag](https://bugsnag.com)'s backend)\n\n```\ntotal: 1.823ms (in 2.213ms real time, max concurrency: 1.2, wait time: 3.688ms)\n0.879: 0.011ms    at Function.Project.fromCache (/0/bugsnag/event-worker/lib/project.coffee:12:16) (0.072ms)\n0.970: 0.363ms    [no mark] (0.250ms)\n1.589: 0.002ms        at /0/bugsnag/event-worker/workers/notify.coffee:29:13 (0.000ms)\n1.622: 0.010ms        at /0/bugsnag/event-worker/workers/notify.coffee:30:13 (0.000ms)\n1.668: 0.043ms        at Event.hash (/0/bugsnag/event-worker/lib/event/event.coffee:238:16) (0.061ms)\n1.780: 0.064ms          at /0/bugsnag/event-worker/lib/event/event.coffee:246:21 (0.098ms)\n2.016: 0.064ms            at Object.exports.count (/0/bugsnag/event-worker/lib/throttling.coffee:12:14) (0.122ms)\n2.250: 0.052ms            REDIS EVAL SCRIPT (0.123)\n2.506: 0.166ms                at throttleProjectEvent (/0/bugsnag/event-worker/lib/throttling.coffee:125:14) (0.295ms)\n2.433: 0.002ms                at throttleProjectEvent (/0/bugsnag/event-worker/lib/throttling.coffee:125:14) (0.000ms)\n2.211: 0.002ms              at throttleAccountEvent (/0/bugsnag/event-worker/lib/throttling.coffee:73:14) (0.000ms)\n1.947: 0.002ms            at Object.exports.count (/0/bugsnag/event-worker/lib/throttling.coffee:12:14) (0.000ms)\n1.593: 0.001ms        at Event.hash (/0/bugsnag/event-worker/lib/event/event.coffee:238:16) (0.000ms)\n0.775: 0.003ms    at Function.Project.fromCache (/0/bugsnag/event-worker/lib/project.coffee:12:16) (0.000ms)\n```\n\nThe first line contains 4 numbers:\n\n* `total` — the total amount of time spent running CPU.\n* `real time` — the amount of time between the first callack starting and the last callback ending.\n* `max concurrency` — is just `real time / total`. Assuming that node is single threaded, and you want to peg the CPU at 100%, how\n    many tasks like this could run concurrently.\n* `wait time` — the sum of the times between each callback being created and being called. High wait times can happen either because\n    you're waiting for a lot of parallel IO events, or because you're waiting for other callbacks to stop using the CPU.\n\nEach subsequent line contains 4 bits of information:\n* `start`: The time since you called `new AsyncProfile()` and when this callback started running.\n* `cpu time`: The amount of CPU time it took to execute this callback.\n* `location`: The point in your code at which this callback was created. (see also [marking](#marking)).\n* `overhead`: The amount of CPU time it took to calculate `location` (see also [speed](#speed)) which has been subtraced from the `cpu time` column.\n\nAdditionally the indentation lets you re-construct the tree of callbacks.\n\n## Marking\n\nSometimes it's hard to figure out exactly what's running when, particularly as the point at which the underlying async callback is created might not\ncorrespond to the location of a callback function in your code. At any point while the profiler is running you can mark the current callback to\nmake it easy to spot in the profiler output.\n\n```javascipt\nAsyncProfile.mark 'SOMETHING EASY TO SPOT'\n```\n\nFor example in the above output, I've done that for the callback that was running `redis.eval` and marked it as `'REDIS EVAL SCRIPT'`.\n\n## Speed\n\nLike all profilers, this one comes with some overhead. In fact, by default it has so much overhead that I had to calculate it and then subtract it from the results :p.\n\nThere is some overhead not included in the overhead numbers, but it should hopefully be fairly insignficant (1-10μs or so per async call) and also not included in the profiler output.\n\nYou can make the profiler faster by creating it with the fast option. This disables both stack-trace calculation, and overhead calculation.\n\n```javascript\nnew AsyncProfile({fast: true})\n```\n\n## Stopping\n*also known as \"help, it's not displaying anything\"*\n\nIf your process happens to make an infinite cascade of callbacks (often this happens with promises libraries), then you will have to manually stop the profiler manually. For example using a promise you might want to do something like:\n\n```javascript\n\nvar p = new AsyncProfile()\nPromise.try(doWork).finally(function () {\n    p.stop();\n});\n```\n\n## Custom reports\n\nYou can pass a callback into the constructor to generate your own output. The default callback looks like this:\n\n```javascript\nnew AsyncProfile({\n    callback: function (result) {\n        result.print();\n    }\n);\n```\n\nYou have access to all the useful properties of the profiler on the result object.\n\n# Common problems\n\n## No output is produced\n\nTry manually [stopping](#stopping) the profiler. You might have an infinite chain of callbacks, or no callbacks at all.\n\n## Some callbacks are missing\n\nWe're using [`async-listener`](https://www.npmjs.org/package/async-listener) under the hood, and it sometimes can't \"see\" beyond\nsome libraries (like redis or mongo) that use connection queues.\n\nThe solution is to manually create a bridge over the asynchronous call. You can look at the code to see how I did it for mongo and\nredis. Pull requests are welcome.\n\n## Crashes on require with async-listener polyfill warning.\n\nEither you're using node 0.11 (congrats!) or you're including\n[`async-listener`](https://www.npmjs.org/package/async-listener) from multiple\nplaces.\n\nYou can fix this by sending a pull request :).\n\n\n# Meta-fu\n\nasync-profile is licensed under the MIT license. Comments, pull-requests and issue reports are welcome.\n\n","maintainers":[{"name":"cirwin","email":"conrad.irwin@gmail.com"}],"time":{"modified":"2022-06-13T03:37:29.107Z","created":"2014-07-11T18:47:43.928Z","0.1.0":"2014-07-11T18:50:36.715Z","0.1.1":"2014-07-11T19:02:36.553Z","0.2.0":"2014-07-12T09:19:02.711Z","0.2.1":"2014-07-12T09:34:21.147Z","0.2.3":"2014-09-18T20:26:35.531Z","0.3.1":"2014-09-19T20:50:20.982Z","0.4.0":"2014-10-03T07:03:04.363Z"},"readmeFilename":"README.md","homepage":"https://github.com/ConradIrwin/async-profile","repository":{"type":"git","url":"https://github.com/ConradIrwin/async-profile"},"bugs":{"url":"https://github.com/ConradIrwin/async-profile/issues"},"users":{"detj":true,"julien-f":true,"asaupup":true,"nuwaio":true}}