22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/sass-prof/formatter.rb', line 22
def to_table(rows)
t_ms = Timer.t_total
return if t_ms.nil?
t_ss, t_ms = t_ms.divmod 1000
t_mm, t_ss = t_ss.divmod 60
Timer::SUMMARIES.reject { |s| s == :t_total }.each do |summary|
break unless Config.subtotal
case summary
when /^(t_)/
sum_t_ms = Timer.send summary
next if sum_t_ms.nil?
sum_t_ss, sum_t_ms = sum_t_ms.divmod 1000
sum_t_mm, sum_t_ss = sum_t_ss.divmod 60
rows << :separator
rows << [
"subtotal",
"%.0fm %.0fs %.0fms" % [sum_t_mm, sum_t_ss, sum_t_ms],
"#{summary}".gsub(/(^(t_)|(_total)$)/, ""),
""
]
when /^(cnt_)/
count = Timer.send summary
next if count.nil?
rows << :separator
rows << [
"count",
"#{count}",
"#{summary}".gsub(/(^(cnt_)|(_total)$)/, ""),
""
]
end
end
rows << :separator
rows << [
"total",
"%.0fm %.0fs %.0fms" % [t_mm, t_ss, t_ms],
"all",
""
]
table = Terminal::Table.new({
:headings => ["file", "execution time", "action", "signature"],
:rows => rows
})
table
end
|