 maxDepth = (node) ->
   return 0 if not node
   return 1 if not node.children
+  return node.maxDepth if node.maxDepth
 
   max = 0
   node.children.forEach (child) ->
     depth = maxDepth(child)
     max = depth if depth > max
 
-  return max + 1
+  node.maxDepth = max + 1
+  return node.maxDepth
 
 
-getLastTwoTokens = (str) ->
-  tokens = str.split(".")
+getClassAndMethodName = (fqdn) ->
+  tokens = fqdn.split(".")
   tokens.slice(tokens.length - 2).join(".")
 
 d3.flameGraph = ->

d3.json "data/profile-large.json", (err, data) ->
  window.flameGraph = d3.flameGraph()
  flameGraph
    .containerId('#d3-flame-graph')
    .width(1200).height(600).cellHeight(10)
    .data(convert(data.profile))
    .colorScheme(["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026"])

            .attr('height', (d) => @cellHeight() - 2)
            .attr('x', (d) => @x(d.x))
            .attr('y', (d) => @y(d.y))
            .attr('stroke', @colorScheme()[@colorScheme().length - 1])
            .attr('fill', (d) => @color(d))
            .attr('fill-opacity', '0.8')

      @container()
        .selectAll('.label')
        .data(@data().filter((d) => d.name and @x(d.dx) > 40))
        .enter()
