webmcp

diff framework/env/trace/_render_sub_tree.lua @ 115:0de41d8e2cf8

Added time protocol to trace system
author bsw
date Thu Jul 10 00:04:45 2014 +0200 (2014-07-10)
parents a54cc7dcabf1
children 32ec28229bb5
line diff
     1.1 --- a/framework/env/trace/_render_sub_tree.lua	Mon Feb 10 20:52:21 2014 +0100
     1.2 +++ b/framework/env/trace/_render_sub_tree.lua	Thu Jul 10 00:04:45 2014 +0200
     1.3 @@ -1,8 +1,39 @@
     1.4  local function open(class)
     1.5    slot.put('<li class="trace_' .. class .. '">')
     1.6  end
     1.7 -local function open_head()
     1.8 +local function open_head(node)
     1.9    slot.put('<div class="trace_head">')
    1.10 +  if node.start_hires_time and node.stop_hires_time then
    1.11 +    local total_duration = node.stop_hires_time - node.start_hires_time
    1.12 +    local child_duration = 0
    1.13 +    for i, child in ipairs(node) do
    1.14 +      if child.start_hires_time and child.stop_hires_time then
    1.15 +        child_duration = child_duration + child.stop_hires_time - child.start_hires_time
    1.16 +      end
    1.17 +    end
    1.18 +    local duration = total_duration - child_duration
    1.19 +    local start_text = math.floor(node.start_hires_time * 10000 + 0.5) / 10
    1.20 +    local total_duration_text = math.floor(total_duration * 10000 + 0.5) / 10
    1.21 +    local child_duration_text = math.floor(child_duration * 10000 + 0.5) / 10
    1.22 +    local duration_text = math.floor(duration * 10000 + 0.5) / 10
    1.23 +    slot.put('<div class="time">')
    1.24 +    slot.put('<span class="start_label">start:</span>')
    1.25 +    slot.put(" ")
    1.26 +    slot.put('<span class="start">' .. start_text .. 'ms</span>')
    1.27 +    slot.put(" | ")
    1.28 +    slot.put('<span class="duration_label">this:</span>')
    1.29 +    slot.put(" ")
    1.30 +    slot.put('<span class="duration">' .. duration_text .. 'ms</span>')
    1.31 +    slot.put(" | ")
    1.32 +    slot.put('<span class="child_duration_label">children:</span>')
    1.33 +    slot.put(" ")
    1.34 +    slot.put('<span class="child_duration">' .. child_duration_text .. 'ms</span>')
    1.35 +    slot.put(" | ")
    1.36 +    slot.put('<span class="total_duration_label">total:</span>')
    1.37 +    slot.put(" ")
    1.38 +    slot.put('<span class="total_duration">' .. total_duration_text .. 'ms</span>')
    1.39 +    slot.put('</div>')
    1.40 +  end
    1.41  end
    1.42  local function close_head()
    1.43    slot.put('</div>')
    1.44 @@ -55,7 +86,7 @@
    1.45      close()
    1.46    elseif node_type == "request" then
    1.47      open("request")
    1.48 -    open_head()
    1.49 +    open_head(node)
    1.50      slot.put("REQUESTED")
    1.51      if node.view then
    1.52        slot.put(" VIEW")
    1.53 @@ -71,17 +102,17 @@
    1.54      close_with_children()
    1.55    elseif node_type == "config" then
    1.56      open("config")
    1.57 -    open_head()
    1.58 +    open_head(node)
    1.59      slot.put('Configuration "', encode.html(node.name), '"')
    1.60      close_with_children()
    1.61    elseif node_type == "filter" then
    1.62      open("filter")
    1.63 -    open_head()
    1.64 +    open_head(node)
    1.65      slot.put(encode.html(node.path))
    1.66      close_with_children()
    1.67    elseif node_type == "view" then
    1.68      open("view")
    1.69 -    open_head()
    1.70 +    open_head(node)
    1.71      slot.put(
    1.72        "EXECUTE VIEW: ",
    1.73        encode.html(node.module),
    1.74 @@ -107,7 +138,7 @@
    1.75      else
    1.76        open("action_neutral")
    1.77      end
    1.78 -    open_head()
    1.79 +    open_head(node)
    1.80      slot.put(
    1.81        "EXECUTE ACTION: ",
    1.82        encode.html(node.module),
    1.83 @@ -127,17 +158,17 @@
    1.84      close()
    1.85    elseif node_type == "redirect" then
    1.86      open("redirect")
    1.87 -    open_head()
    1.88 +    open_head(node)
    1.89      slot.put("303 REDIRECT TO VIEW: ", encode.html(node.module), "/", encode.html(node.view))
    1.90      close_with_children()
    1.91    elseif node_type == "forward" then
    1.92      open("forward")
    1.93 -    open_head()
    1.94 +    open_head(node)
    1.95      slot.put("INTERNAL FORWARD TO VIEW: ", encode.html(node.module), "/", encode.html(node.view))
    1.96      close_with_children()
    1.97    elseif node_type == "exectime" then
    1.98      open("exectime")
    1.99 -    open_head()
   1.100 +    open_head(node)
   1.101      slot.put(
   1.102        "Finished after " ..
   1.103        string.format("%.1f", extos.monotonic_hires_time() * 1000) ..
   1.104 @@ -164,7 +195,7 @@
   1.105      close();
   1.106    elseif node_type == "error" then
   1.107      open("error")
   1.108 -    open_head()
   1.109 +    open_head(node)
   1.110      slot.put("UNEXPECTED ERROR")
   1.111      close_head()
   1.112      close()

Impressum / About Us