flamegraph
Version:
Generates flamegraphs with Node.js or in the browser
1 lines • 74.2 kB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.flamegraph=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){var svg=require("./lib/svg");var defaultOpts=require("./lib/default-opts");var defaultOptsMeta=require("./lib/default-opts-meta");var cpuprofilify=require("cpuprofilify");var cpuprofileProcessor=require("./lib/cpuprofile-processor");function processCpuProfile(cpuprofile,opts){return cpuprofileProcessor(cpuprofile,opts).process()}function fromCpuProfile(cpuprofile,opts){var processed=processCpuProfile(cpuprofile,opts);return svg(processed,opts)}exports=module.exports=function flamegraph(arr,opts){var profile;if(!Array.isArray(arr))throw new TypeError("First arg needs to be an array of lines.");opts=opts||{};try{profile=cpuprofilify().convert(arr,opts.profile)}catch(err){try{profile=JSON.parse(arr.join("\n"))}catch(parseErr){throw err}}return fromCpuProfile(profile,opts)};exports.svg=svg;exports.defaultOpts=defaultOpts;exports.defaultOptsMeta=defaultOptsMeta;exports.processCpuProfile=processCpuProfile;exports.fromCpuProfile=fromCpuProfile},{"./lib/cpuprofile-processor":4,"./lib/default-opts":6,"./lib/default-opts-meta":5,"./lib/svg":9,cpuprofilify:15}],2:[function(require,module,exports){var format=require("util").format;function scalarReverse(s){return s.split("").reverse().join("")}function nameHash(name){var vector=0;var weight=1;var max=1;var mod=10;var ord;name=name.replace(/.(.*?)`/,"");var splits=name.split("");for(var i=0;i<splits.length;i++){ord=splits[i].charCodeAt(0)%mod;vector+=ord/(mod++-1)*weight;max+=weight;weight*=.7;if(mod>12)break}return 1-vector/max}function color(type,hash,name){var v1,v2,v3,r,g,b;if(!type)return"rgb(0, 0, 0)";if(hash){v1=nameHash(name);v2=v3=nameHash(scalarReverse(name))}else{v1=Math.random()+1;v2=Math.random()+1;v3=Math.random()+1}switch(type){case"hot":r=205+Math.round(50*v3);g=0+Math.round(230*v1);b=0+Math.round(55*v2);return format("rgb(%s, %s, %s)",r,g,b);case"mem":r=0;g=190+Math.round(50*v2);b=0+Math.round(210*v1);return format("rgb(%s, %s, %s)",r,g,b);case"io":r=80+Math.round(60*v1);g=r;b=190+Math.round(55*v2);return format("rgb(%s, %s, %s)",r,g,b);default:throw new Error("Unknown type "+type)}}module.exports=function colorMap(paletteMap,colorTheme,hash,func){if(paletteMap[func])return paletteMap[func];paletteMap[func]=color(colorTheme,hash,func);return paletteMap[func]}},{util:14}],3:[function(require,module,exports){var xtend=require("xtend");var format=require("util").format;var colorMap=require("./color-map");function oneDecimal(x){return Math.round(x*10)/10}function htmlEscape(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}module.exports=function contextify(parsed,opts){var time=parsed.time;var timeMax=opts.timemax;var ypadTop=opts.fontsize*4;var ypadBottom=opts.fontsize*2+10;var xpad=10;var depthMax=0;var frameHeight=opts.frameheight;var paletteMap={};if(timeMax<time&&timeMax/time>.02){console.error("Specified timemax %d is less than actual total %d, so it will be ignored",timeMax,time);timeMax=Infinity}timeMax=Math.min(time,timeMax);var widthPerTime=(opts.imagewidth-2*xpad)/timeMax;var minWidthTime=opts.minwidth/widthPerTime;function markNarrowBlocks(nodes){function mark(k){var val=parsed.nodes[k];if(typeof val.stime!=="number")throw new Error("Missing start for "+k);if(val.etime-val.stime<minWidthTime){val.narrow=true;return}val.narrow=false;depthMax=Math.max(val.depth,depthMax)}Object.keys(nodes).forEach(mark)}function processNode(node){var func=node.func;var depth=node.depth;var etime=node.etime;var stime=node.stime;var factor=opts.factor;var countName=opts.countname;var isRoot=!func.length&&depth===0;if(isRoot)etime=timeMax;var samples=Math.round((etime-stime*factor)*10)/10;var samplesTxt=samples.toLocaleString();var pct;var pctTxt;var escapedFunc;var name;var sampleInfo;if(isRoot){name="all";sampleInfo=format("(%s %s, 100%)",samplesTxt,countName)}else{pct=Math.round(100*samples/(timeMax*factor)*10)/10;pctTxt=pct.toLocaleString();escapedFunc=htmlEscape(func);name=escapedFunc;sampleInfo=format("(%s %s), %s%%)",samplesTxt,countName,pctTxt)}var x1=oneDecimal(xpad+stime*widthPerTime);var x2=oneDecimal(xpad+etime*widthPerTime);var y1=oneDecimal(imageHeight-ypadBottom-(depth+1)*frameHeight+1);var y2=oneDecimal(imageHeight-ypadBottom-depth*frameHeight);var chars=(x2-x1)/(opts.fontsize*opts.fontwidth);var showText=false;var text;if(chars>=3){showText=true;text=func.slice(0,chars);if(chars<func.length)text=text.slice(0,chars-2)+"..";text=htmlEscape(text)}return{name:name,search:name.toLowerCase(),samples:sampleInfo,rect_x:x1,rect_y:y1,rect_w:x2-x1,rect_h:y2-y1,rect_fill:colorMap(paletteMap,opts.colors,opts.hash,func),text:text,text_x:x1+(showText?3:0),text_y:3+(y1+y2)/2,narrow:node.narrow,func:htmlEscape(func)}}function processNodes(nodes){var keys=Object.keys(nodes);var acc=new Array(keys.length);for(var i=0;i<keys.length;i++){acc[i]=processNode(nodes[keys[i]])}return acc}markNarrowBlocks(parsed.nodes);var imageHeight=depthMax*frameHeight+ypadTop+ypadBottom;var ctx=xtend(opts,{imageheight:imageHeight,xpad:xpad,titleX:opts.imagewidth/2,detailsY:imageHeight-frameHeight/2});ctx.nodes=processNodes(parsed.nodes);return ctx}},{"./color-map":2,util:14,xtend:38}],4:[function(require,module,exports){function funcName(node){var n=node.functionName;if(node.url)n+=" "+node.url+":"+node.lineNumber;return n}function byFramesLexically(a,b){var i=0;var framesA=a.frames;var framesB=b.frames;while(true){if(!framesA[i])return-1;if(!framesB[i])return 1;if(framesA[i]<framesB[i])return-1;if(framesB[i]<framesA[i])return 1;i++}}function sort(functions){return functions.sort(byFramesLexically)}function CpuProfileProcessor(cpuprofile){if(!(this instanceof CpuProfileProcessor))return new CpuProfileProcessor(cpuprofile);this._profile=cpuprofile;this._paths=[];this._time=0;this._last=[];this._tmp={};this._nodes={}}var proto=CpuProfileProcessor.prototype;module.exports=CpuProfileProcessor;proto._explorePaths=function _explorePaths(node,stack){stack.push(funcName(node));if(node.hitCount)this._paths.push({frames:stack.slice(),hitCount:node.hitCount});for(var i=0;i<node.children.length;i++){this._explorePaths(node.children[i],stack)}stack.pop()};proto._flow=function _flow(frames){var lenLast=this._last.length-1;var lenFrames=frames.length-1;var i;var lenSame;var k;for(i=0;i<=lenLast;i++){if(i>lenFrames)break;if(this._last[i]!==frames[i])break}lenSame=i;for(i=lenLast;i>=lenSame;i--){k=this._last[i]+";"+i;this._nodes[k+";"+this._time]={func:this._last[i],depth:i,etime:this._time,stime:this._tmp[k].stime};this._tmp[k]=null}for(i=lenSame;i<=lenFrames;i++){k=frames[i]+";"+i;this._tmp[k]={stime:this._time}}};proto._processPath=function _processPath(path){this._flow(path.frames);this._time+=path.hitCount;this._last=path.frames};proto._processPaths=function _processPaths(){sort(this._paths);for(var i=0;i<this._paths.length;i++){this._processPath(this._paths[i])}this._flow([])};proto.process=function process(){this._explorePaths(this._profile.head,[]);this._processPaths();return{nodes:this._nodes,time:this._time}}},{}],5:[function(require,module,exports){module.exports={fonttype:{type:"string",description:"Font Type"},fontsize:{type:"range",description:"Font Size",min:6,max:22,step:.1},imagewidth:{type:"range",description:"Image Width",min:200,max:2400,step:5},frameheight:{type:"range",description:"Frame Height",min:6,max:40,step:.1},fontwidth:{type:"range",description:"Font Width",min:.2,max:1,step:.05},minwidth:{type:"range",description:"Min Function Width",min:.1,max:30,step:.1},countname:{type:"string",description:"Count Name"},colors:{type:"string",description:"Color Theme"},bgcolor1:{type:"color",description:"Gradient start"},bgcolor2:{type:"color",description:"Gradient stop"},timemax:{type:"number",description:"Time Max"},factor:{type:"number",description:"Scaling Factor"},hash:{type:"boolean",description:"Color by Function Name"},titlestring:{type:"string",description:"Title"},nametype:{type:"string",description:"Name"},internals:{type:"checkbox",description:"Show Internals",checked:""}}},{}],6:[function(require,module,exports){module.exports={fonttype:"Verdana",fontsize:12,imagewidth:1200,frameheight:16,fontwidth:.59,minwidth:.1,countname:"samples",colors:"hot",bgcolor1:"#eeeeee",bgcolor2:"#eeeeb0",timemax:Infinity,factor:1,hash:true,titletext:"Flame Graph",nametype:"Function:",palette:false,palette_map:{},pal_file:"palette.map",removenarrows:true,profile:{shortStack:true,unresolveds:false,v8internals:false,v8gc:true,sysinternals:false}}},{}],7:[function(require,module,exports){module.exports=require("./svg.hbs")},{"./svg.hbs":8}],8:[function(require,module,exports){var Handlebars=require("hbsfy/runtime");module.exports=Handlebars.template({1:function(depth0,helpers,partials,data,depths){var stack1,helper,functionType="function",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression,lambda=this.lambda,buffer='<g class="func_g '+escapeExpression((helper=(helper=helpers["class"]||(depth0!=null?depth0["class"]:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"class",hash:{},data:data}):helper))+"\" onmouseover=\"typeof s === 'function' && s('";stack1=(helper=(helper=helpers.name||(depth0!=null?depth0.name:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"name",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+=" ";stack1=(helper=(helper=helpers.samples||(depth0!=null?depth0.samples:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"samples",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+='\')" onmouseout="typeof c === \'function\' && c()" data-search="';stack1=(helper=(helper=helpers.search||(depth0!=null?depth0.search:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"search",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+='" data-funcname="';stack1=(helper=(helper=helpers.func||(depth0!=null?depth0.func:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"func",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+='">\n <title>';stack1=(helper=(helper=helpers.name||(depth0!=null?depth0.name:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"name",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+=" ";stack1=(helper=(helper=helpers.samples||(depth0!=null?depth0.samples:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"samples",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+='</title>\n <rect x="'+escapeExpression((helper=(helper=helpers.rect_x||(depth0!=null?depth0.rect_x:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_x",hash:{},data:data}):helper))+'" data-x="'+escapeExpression((helper=(helper=helpers.rect_x||(depth0!=null?depth0.rect_x:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_x",hash:{},data:data}):helper))+'" y="'+escapeExpression((helper=(helper=helpers.rect_y||(depth0!=null?depth0.rect_y:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_y",hash:{},data:data}):helper))+'" width="'+escapeExpression((helper=(helper=helpers.rect_w||(depth0!=null?depth0.rect_w:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_w",hash:{},data:data}):helper))+'" data-width="'+escapeExpression((helper=(helper=helpers.rect_w||(depth0!=null?depth0.rect_w:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_w",hash:{},data:data}):helper))+'" height="'+escapeExpression((helper=(helper=helpers.rect_h||(depth0!=null?depth0.rect_h:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_h",hash:{},data:data}):helper))+'" data-height="'+escapeExpression((helper=(helper=helpers.rect_h||(depth0!=null?depth0.rect_h:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_h",hash:{},data:data}):helper))+'" fill="'+escapeExpression((helper=(helper=helpers.rect_fill||(depth0!=null?depth0.rect_fill:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"rect_fill",hash:{},data:data}):helper))+'" rx="2" ry="2"></rect>\n <text data-x="'+escapeExpression((helper=(helper=helpers.text_x||(depth0!=null?depth0.text_x:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"text_x",hash:{},data:data}):helper))+'" x="'+escapeExpression((helper=(helper=helpers.text_x||(depth0!=null?depth0.text_x:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"text_x",hash:{},data:data}):helper))+'" y="'+escapeExpression((helper=(helper=helpers.text_y||(depth0!=null?depth0.text_y:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"text_y",hash:{},data:data}):helper))+'" font-size="'+escapeExpression(lambda(depths[1]!=null?depths[1].fontsize:depths[1],depth0))+'" font-family="'+escapeExpression(lambda(depths[1]!=null?depths[1].fonttype:depths[1],depth0))+'" fill="rgb(0,0,0)">';stack1=(helper=(helper=helpers.text||(depth0!=null?depth0.text:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"text",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}return buffer+"</text>\n</g>\n"},compiler:[6,">= 2.0.0-beta.1"],main:function(depth0,helpers,partials,data,depths){var stack1,helper,functionType="function",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression,buffer='<?xml version="1.0" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n\n<svg version="1.1" id="flamegraph-svg" \n data-width="'+escapeExpression((helper=(helper=helpers.imagewidth||(depth0!=null?depth0.imagewidth:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imagewidth",hash:{},data:data}):helper))+'" width="'+escapeExpression((helper=(helper=helpers.imagewidth||(depth0!=null?depth0.imagewidth:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imagewidth",hash:{},data:data}):helper))+'" \n height="'+escapeExpression((helper=(helper=helpers.imageheight||(depth0!=null?depth0.imageheight:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imageheight",hash:{},data:data}):helper))+'" data-height="'+escapeExpression((helper=(helper=helpers.imageheight||(depth0!=null?depth0.imageheight:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imageheight",hash:{},data:data}):helper))+'"\n onload="init(evt)" \n viewBox="0 0 '+escapeExpression((helper=(helper=helpers.imagewidth||(depth0!=null?depth0.imagewidth:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imagewidth",hash:{},data:data}):helper))+" "+escapeExpression((helper=(helper=helpers.imageheight||(depth0!=null?depth0.imageheight:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imageheight",hash:{},data:data}):helper))+'" \n xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\n<defs>\n\t<linearGradient id="background" y1="0" y2="1" x1="0" x2="0">\n <stop stop-color="'+escapeExpression((helper=(helper=helpers.bgcolor1||(depth0!=null?depth0.bgcolor1:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"bgcolor1",hash:{},data:data}):helper))+'" offset="5%" />\n <stop stop-color="'+escapeExpression((helper=(helper=helpers.bgcolor2||(depth0!=null?depth0.bgcolor2:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"bgcolor2",hash:{},data:data}):helper))+'" offset="95%" />\n\t</linearGradient>\n</defs>\n<style type="text/css">\n\t.func_g:hover { stroke:black; stroke-width:0.5; }\n</style>\n<script type="text/javascript">\n\tvar details;\n\tfunction init(evt) { details = document.getElementById("details").firstChild; }\n function s(info) { details.nodeValue = "'+escapeExpression((helper=(helper=helpers.nametype||(depth0!=null?depth0.nametype:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"nametype",hash:{},data:data}):helper))+': " + info; }\n\tfunction c() { details.nodeValue = \' \'; }\n<\/script>\n\n<rect x="0.0" y="0" id="svg-background" width="'+escapeExpression((helper=(helper=helpers.imagewidth||(depth0!=null?depth0.imagewidth:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imagewidth",hash:{},data:data}):helper))+'" height="'+escapeExpression((helper=(helper=helpers.imageheight||(depth0!=null?depth0.imageheight:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"imageheight",hash:{},data:data}):helper))+'" fill="url(#background)" />\n\x3c!--<text text-anchor="middle" x="'+escapeExpression((helper=(helper=helpers.titleX||(depth0!=null?depth0.titleX:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"titleX",hash:{},data:data}):helper))+'" y="24" font-size="17" font-family="'+escapeExpression((helper=(helper=helpers.fonttype||(depth0!=null?depth0.fonttype:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"fonttype",hash:{},data:data}):helper))+'" fill="rgb(0,0,0)">';stack1=(helper=(helper=helpers.titletext||(depth0!=null?depth0.titletext:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"titletext",hash:{},data:data}):helper);if(stack1!=null){buffer+=stack1}buffer+='</text>--\x3e\n<text text-anchor="left" x="'+escapeExpression((helper=(helper=helpers.xpad||(depth0!=null?depth0.xpad:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"xpad",hash:{},data:data}):helper))+'" y="'+escapeExpression((helper=(helper=helpers.detailsY||(depth0!=null?depth0.detailsY:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"detailsY",hash:{},data:data}):helper))+'" font-size="'+escapeExpression((helper=(helper=helpers.fontsize||(depth0!=null?depth0.fontsize:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"fontsize",hash:{},data:data}):helper))+'" font-family="'+escapeExpression((helper=(helper=helpers.fonttype||(depth0!=null?depth0.fonttype:depth0))!=null?helper:helperMissing,typeof helper===functionType?helper.call(depth0,{name:"fonttype",hash:{},data:data}):helper))+'" fill="rgb(0,0,0)" id="details"> </text>\n\n';stack1=helpers.each.call(depth0,depth0!=null?depth0.nodes:depth0,{name:"each",hash:{},fn:this.program(1,data,depths),inverse:this.noop,data:data});if(stack1!=null){buffer+=stack1}return buffer+"\n</svg>\n"},useData:true,useDepths:true})},{"hbsfy/runtime":36}],9:[function(require,module,exports){var xtend=require("xtend");var contextify=require("./contextify");var svgTemplate=require("./svg-template");var defaultOpts=require("./default-opts");function narrowify(context,opts){function processNode(n){n.class=n.narrow?"hidden":""}function filterNode(n){return!n.narrow}if(opts.removenarrows)context.nodes=context.nodes.filter(filterNode);else context.nodes.forEach(processNode)}module.exports=function svg(processedCpuProfile,opts){opts=xtend(defaultOpts,opts);var context=contextify(processedCpuProfile,opts);narrowify(context,opts);return svgTemplate(context)}},{"./contextify":3,"./default-opts":6,"./svg-template":7,xtend:38}],10:[function(require,module,exports){var objectCreate=Object.create||objectCreatePolyfill;var objectKeys=Object.keys||objectKeysPolyfill;var bind=Function.prototype.bind||functionBindPolyfill;function EventEmitter(){if(!this._events||!Object.prototype.hasOwnProperty.call(this,"_events")){this._events=objectCreate(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;var hasDefineProperty;try{var o={};if(Object.defineProperty)Object.defineProperty(o,"x",{value:0});hasDefineProperty=o.x===0}catch(err){hasDefineProperty=false}if(hasDefineProperty){Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||arg!==arg)throw new TypeError('"defaultMaxListeners" must be a positive number');defaultMaxListeners=arg}})}else{EventEmitter.defaultMaxListeners=defaultMaxListeners}EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||isNaN(n))throw new TypeError('"n" argument must be a positive number');this._maxListeners=n;return this};function $getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return $getMaxListeners(this)};function emitNone(handler,isFn,self){if(isFn)handler.call(self);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self)}}function emitOne(handler,isFn,self,arg1){if(isFn)handler.call(self,arg1);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1)}}function emitTwo(handler,isFn,self,arg1,arg2){if(isFn)handler.call(self,arg1,arg2);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1,arg2)}}function emitThree(handler,isFn,self,arg1,arg2,arg3){if(isFn)handler.call(self,arg1,arg2,arg3);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].call(self,arg1,arg2,arg3)}}function emitMany(handler,isFn,self,args){if(isFn)handler.apply(self,args);else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i<len;++i)listeners[i].apply(self,args)}}EventEmitter.prototype.emit=function emit(type){var er,handler,len,args,i,events;var doError=type==="error";events=this._events;if(events)doError=doError&&events.error==null;else if(!doError)return false;if(doError){if(arguments.length>1)er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Unhandled "error" event. ('+er+")");err.context=er;throw err}return false}handler=events[type];if(!handler)return false;var isFn=typeof handler==="function";len=arguments.length;switch(len){case 1:emitNone(handler,isFn,this);break;case 2:emitOne(handler,isFn,this,arguments[1]);break;case 3:emitTwo(handler,isFn,this,arguments[1],arguments[2]);break;case 4:emitThree(handler,isFn,this,arguments[1],arguments[2],arguments[3]);break;default:args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];emitMany(handler,isFn,this,args)}return true};function _addListener(target,type,listener,prepend){var m;var events;var existing;if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');events=target._events;if(!events){events=target._events=objectCreate(null);target._eventsCount=0}else{if(events.newListener){target.emit("newListener",type,listener.listener?listener.listener:listener);events=target._events}existing=events[type]}if(!existing){existing=events[type]=listener;++target._eventsCount}else{if(typeof existing==="function"){existing=events[type]=prepend?[listener,existing]:[existing,listener]}else{if(prepend){existing.unshift(listener)}else{existing.push(listener)}}if(!existing.warned){m=$getMaxListeners(target);if(m&&m>0&&existing.length>m){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+' "'+String(type)+'" listeners '+"added. Use emitter.setMaxListeners() to "+"increase limit.");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;if(typeof console==="object"&&console.warn){console.warn("%s: %s",w.name,w.message)}}}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;switch(arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:var args=new Array(arguments.length);for(var i=0;i<args.length;++i)args[i]=arguments[i];this.listener.apply(this.target,args)}}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=bind.call(onceWrapper,state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;if(typeof listener!=="function")throw new TypeError('"listener" argument must be a function');events=this._events;if(!events)return this;list=events[type];if(!list)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=objectCreate(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else spliceOne(list,position);if(list.length===1)events[type]=list[0];if(events.removeListener)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(!events)return this;if(!events.removeListener){if(arguments.length===0){this._events=objectCreate(null);this._eventsCount=0}else if(events[type]){if(--this._eventsCount===0)this._events=objectCreate(null);else delete events[type]}return this}if(arguments.length===0){var keys=objectKeys(events);var key;for(i=0;i<keys.length;++i){key=keys[i];if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events=objectCreate(null);this._eventsCount=0;return this}listeners=events[type];if(typeof listeners==="function"){this.removeListener(type,listeners)}else if(listeners){for(i=listeners.length-1;i>=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(!events)return[];var evlistener=events[type];if(!evlistener)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(list,index){for(var i=index,k=i+1,n=list.length;k<n;i+=1,k+=1)list[i]=list[k];list.pop()}function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i<n;++i)copy[i]=arr[i];return copy}function unwrapListeners(arr){var ret=new Array(arr.length);for(var i=0;i<ret.length;++i){ret[i]=arr[i].listener||arr[i]}return ret}function objectCreatePolyfill(proto){var F=function(){};F.prototype=proto;return new F}function objectKeysPolyfill(obj){var keys=[];for(var k in obj)if(Object.prototype.hasOwnProperty.call(obj,k)){keys.push(k)}return k}function functionBindPolyfill(context){var fn=this;return function(){return fn.apply(context,arguments)}}},{}],11:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],12:[function(require,module,exports){var process=module.exports={};var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){cachedSetTimeout=setTimeout}else{cachedSetTimeout=defaultSetTimout}}catch(e){cachedSetTimeout=defaultSetTimout}try{if(typeof clearTimeout==="function"){cachedClearTimeout=clearTimeout}else{cachedClearTimeout=defaultClearTimeout}}catch(e){cachedClearTimeout=defaultClearTimeout}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){return setTimeout(fun,0)}if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0)}try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){return clearTimeout(marker)}if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker)}try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;runClearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(name){return[]};process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],13:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],14:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":13,_process:12,inherits:11}],15:[function(require,module,exports){var filterInternals=require("trace-filter-internals");var traceUtil=require("./lib/trace-util");var getConverter=require("./lib/get-converter");var resolveSymbols=require("./lib/resolve-symbols");var resolveSymbolsFromMap=require("./lib/resolve-symbols-from-map");var xtend=require("xtend");var inherits=require("inherits");var EventEmitter=require("events").EventEmitter;function CpuProfilifier(){if(!(this instanceof CpuProfilifier))return new CpuProfilifier;EventEmitter.call(this)}inherits(CpuProfilifier,EventEmitter);var proto=CpuProfilifier.prototype;module.exports=CpuProfilifier;proto.convert=function convert(trace,opts){opts=opts||{};this._map=opts.map;this._opts=xtend({v8gc:true},opts,{map:this._map?"was supplied":"was not supplied"});this.emit("info","Options: %j",this._opts);this._trace=trace;this._traceLen=trace.length;if(!this._traceLen){this.emit("warn","Trace was empty, quitting");return}try{this._traceStart=traceUtil.traceStart(this._trace);this._converterCtr=getConverter(this._trace,this._traceStart,this._opts.type);this._resolveTraceInfo();this._tryResolveSymbols();this._filterInternals();var converter=this._converterCtr(this._filtered,this._traceStart,this._opts);this.emit("info","Converting trace of length %d",this._filteredLen);var converted=converter.convert();this.emit("info","Success!");return converted}catch(err){this.emit("error",err)}};proto._tryResolveSymbols=function _tryResolveSymbols(){var res=this._map?resolveSymbolsFromMap(this._map,this._trace):resolveSymbols(this.traceInfo.pid,this._trace);if(res.resolved){this.emit("info","Resolved symbols in trace.");this._trace=res.resolved;return}this.emit("warn",res.reason)};proto._resolveTraceInfo=function _resolveTraceInfo(){var converter=this._converterCtr(this._trace,this._traceStart,this._opts);converter._parseTraceInfo(this._trace[this._traceStart],true);this.traceInfo={process:converter._process,pid:converter._pid,startTime:converter._startTime,type:converter._type};this.emit("info","Trace info: %j",this.traceInfo)};proto._filterInternals=function _filterInternals(){this._filtered=this._trace;this._filtered=filterInternals(this._trace,this._opts);this._filteredLen=this._filtered.length;this.emit("info","Filtered %d internals from given trace",this._traceLen-this._filteredLen)}},{"./lib/get-converter":20,"./lib/resolve-symbols":23,"./lib/resolve-symbols-from-map":22,"./lib/trace-util":24,events:10,inherits:25,"trace-filter-internals":37,xtend:38}],16:[function(require,module,exports){var inherits=require("inherits");var Converter=require("./converter");function DTraceConverter(trace,traceStart,opts){if(!(this instanceof DTraceConverter))return new DTraceConverter(trace,traceStart,opts);Converter.call(this,trace,traceStart,opts);this._frameProcessRegex=new RegExp("^("+this._process+"|node)`")}inherits(DTraceConverter,Converter);var proto=DTraceConverter.prototype;proto._framePartsRegex=/(.+?) (.+?):(\d+)$/;proto._parseFrame=function _parseFrame(frame){var m=frame.match(this._framePartsRegex);if(!m){return{functionName:frame,url:"",lineNumber:0,scriptId:0}}var functionName=m[1];var script=m[2];var lineNumber=m[3];var scriptId=this._scriptIds[script];if(!scriptId){scriptId=this._scriptId++;this._scriptIds[script]=scriptId}if(/^[~*]\s*$/.test(functionName))functionName+=" <anonymous>";return{functionName:functionName,lineNumber:lineNumber,url:script,scriptId:scriptId}};proto._parseTraceInfo=function _parseTraceInfo(line,isStart){var parts=line.split(/\s+/);if(!isStart){this._endTime=parts[2]&&parts[2].slice(0,-1)||"0";return}if(this._startTime&&this._process&&this._pid&&this._type)return;this._startTime=parts[2]&&parts[2].slice(0,-1)||"0.0";this._process=parts[0];this._pid=parts[1];this._type=parts[3]||""};proto._normalizeFrame=function _normalizeFrame(frame){return this.removeOptimizationInfo(frame.trim().replace(this._frameAddressRegex,"").replace(this._frameProcessRegex,"").replace(this._frameJSAddressRegex,""))};proto._adjustTime=function _adjustTime(t){var s=t.toString();if(s.length<5)return s;return s.slice(0,-3)+"."+s.slice(4)};proto._frameAddressRegex=/\+0x[0-9a-fA-F]+$/;proto._frameJSAddressRegex=/0x[0-9a-fA-F]+( LazyCompile:| Function:| Script:){0,1}/;proto.type="dtrace";exports=module.exports=DTraceConverter;exports.ctor=DTraceConverter;exports.proto=proto},{"./converter":18,inherits:25}],17:[function(require,module,exports){var inherits=require("inherits");var Converter=require("./converter");var DTraceConverter=require("./converter-dtrace").proto;function PerfConverter(trace,traceStart,opts){if(!(this instanceof PerfConverter))return new PerfConverter(trace,traceStart,opts);Converter.call(this,trace,traceStart,opts)}inherits(PerfConverter,Converter);var proto=PerfConverter.prototype;proto._frameRegex=/^\w+\s+(?:LazyCompile:|Function:|Script:){0,1}(.+?)\W\(\S+\)$/;proto._framePartsRegex=/^(.+?)([\S.]+):(\d+)$/;proto._parseFrame=function _parseFrame(frame){return DTraceConverter._parseFrame.call(this,frame)};proto._parseTraceInfo=function _parseTraceInfo(line,isStart){DTraceConverter._parseTraceInfo.call(this,line,isStart)};proto._normalizeFrame=function _normalizeFrame(frame){return this.removeOptimizationInfo(frame.trim().replace(this._frameRegex,"$1"))};proto._adjustTime=function _adjustTime(t){return parseInt(t.toString().slice(0,-4))};proto.type="perf";exports=module.exports=PerfConverter;exports.ctor=PerfConverter;exports.proto=proto},{"./converter":18,"./converter-dtrace":16,inherits:25}],18:[function(require,module,exports){var cpuprofile=require("./cpuprofile");var traceUtil=require("./trace-util");var roi=require("./remove-optimization-info");function Converter(trace,traceStart,opts){if(!(this instanceof Converter))return new Converter(trace,traceStart,opts);opts=opts||{};this._trace=traceUtil.normalizeEmptyLines(trace);this._traceStart=traceStart;this._id=0;this._scriptId=0;this._scriptIds={};this._process=undefined;this._pid=undefined;this._type=undefined;this._startTime=undefined;this._endTime=undefined;this._parseTraceInfo(trace[this._traceStart],true);this._head=cpuprofile.createHead(this._process,this._scriptId++);this._samples=[];this._optimizationinfo=opts.optimizationinfo;this._shortStacks=opts.shortStacks}var proto=Converter.prototype;proto._parseFrame=function _parseFrame(frame){throw new Error("Need to implement _parseFrame.")};proto._parseTraceInfo=function _parseTraceInfo(frame){throw new Error("Need to implement _parseTraceInfo.")};proto._normalizeFrame=function _normalizeFrame(frame){throw new Error("Need to implement _normalizeFrame.")};proto._adjustTime=function _adjustTime(frame){throw new Error("Need to implement _adjustTime.")};proto.findOrCreateNode=function findOrCreateNode(parent,nextId,stackFrame){var child;for(var i=0;i<parent.children.length;i++){child=parent.children[i];if(child._stackFrame===stackFrame){return child}}var opts=this._parseFrame(stackFrame);var node=cpuprofile.createNode(nextId,stackFrame,opts);parent.children.push(node);return node};proto.obj