webmcp
diff framework/env/trace/_render_sub_tree.lua @ 299:47c5f33e4a6b
Trace real time and CPU time
author | jbe |
---|---|
date | Sun Mar 22 19:25:38 2015 +0100 (2015-03-22) |
parents | e0b6cb626ee6 |
children | d1d21ae9acdb |
line diff
1.1 --- a/framework/env/trace/_render_sub_tree.lua Sun Mar 22 18:58:50 2015 +0100 1.2 +++ b/framework/env/trace/_render_sub_tree.lua Sun Mar 22 19:25:38 2015 +0100 1.3 @@ -1,5 +1,9 @@ 1.4 -local function format_time(seconds) 1.5 - return string.format("%.1f ms", seconds * 1000) 1.6 +local function format_time(real_time, proc_time) 1.7 + if proc_time then 1.8 + return string.format("%.1f ms (%.1%f ms CPU)", real_time * 1000, proc_time * 1000) 1.9 + else 1.10 + return string.format("%.1f ms", real_time * 1000) 1.11 + end 1.12 end 1.13 1.14 local function open(class) 1.15 @@ -7,36 +11,34 @@ 1.16 end 1.17 local function open_head(node) 1.18 slot.put('<div class="trace_head">') 1.19 - if node.start_hires_time and node.stop_hires_time then 1.20 - local total_duration = node.stop_hires_time - node.start_hires_time 1.21 - local child_duration = 0 1.22 + if node.start_real_time and node.stop_real_time then 1.23 + local total_real_time = node.stop_real_time - node.start_real_time 1.24 + local total_proc_time = node.stop_proc_time - node.start_proc_time 1.25 + local child_real_time = 0 1.26 + local child_proc_time = 0 1.27 for i, child in ipairs(node) do 1.28 - if child.start_hires_time and child.stop_hires_time then 1.29 - child_duration = child_duration + child.stop_hires_time - child.start_hires_time 1.30 + if child.start_real_time then 1.31 + child_real_time = child_real_time + child.stop_real_time - child.start_real_time 1.32 + child_proc_time = child_proc_time + child.stop_proc_time - child.start_proc_time 1.33 end 1.34 end 1.35 - local duration = total_duration - child_duration 1.36 - local start_text = math.floor(node.start_hires_time * 10000 + 0.5) / 10 1.37 - local total_duration_text = math.floor(total_duration * 10000 + 0.5) / 10 1.38 - local child_duration_text = math.floor(child_duration * 10000 + 0.5) / 10 1.39 - local duration_text = math.floor(duration * 10000 + 0.5) / 10 1.40 - slot.put('<div class="time">') 1.41 - slot.put('<span class="start_label">start:</span>') 1.42 - slot.put(" ") 1.43 - slot.put('<span class="start">' .. start_text .. 'ms</span>') 1.44 - slot.put(" | ") 1.45 - slot.put('<span class="duration_label">this:</span>') 1.46 - slot.put(" ") 1.47 - slot.put('<span class="duration">' .. duration_text .. 'ms</span>') 1.48 - slot.put(" | ") 1.49 - slot.put('<span class="child_duration_label">children:</span>') 1.50 - slot.put(" ") 1.51 - slot.put('<span class="child_duration">' .. child_duration_text .. 'ms</span>') 1.52 - slot.put(" | ") 1.53 - slot.put('<span class="total_duration_label">total:</span>') 1.54 - slot.put(" ") 1.55 - slot.put('<span class="total_duration">' .. total_duration_text .. 'ms</span>') 1.56 - slot.put('</div>') 1.57 + local real_time = total_real_time - child_real_time 1.58 + local proc_time = total_proc_time - child_proc_time 1.59 + slot.put( 1.60 + '<div class="time">', 1.61 + '<span class="duration_label">this:</span>', 1.62 + ' ', 1.63 + '<span class="duration">', format_time(real_time, proc_time), '</span>', 1.64 + ' | ', 1.65 + '<span class="child_duration_label">children:</span>', 1.66 + ' ', 1.67 + '<span class="child_duration">', format_time(child_real_time, child_proc_time), '</span>', 1.68 + ' | ', 1.69 + '<span class="total_duration_label">total:</span>', 1.70 + ' ', 1.71 + '<span class="total_duration">', format_time(total_real_time, total_proc_time), '</span>', 1.72 + '</div>' 1.73 + ) 1.74 end 1.75 end 1.76 local function close_head()