7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|
# File 'lib/kiss/bench.rb', line 7
def prepend_benchmarks(document)
html = "<style>\n.kiss_bench {\n text-align: left;\n padding: 3px 7px;\n border: 1px solid #ec4;\n border-top: 1px solid #fff4bb;\n border-bottom: 1px solid #d91;\n background-color: #ffe590;\n font-size: 12px;\n color: #101;\n}\n.kiss_bench a {\n color: #930;\n text-decoration: none;\n}\n.kiss_bench a:hover {\n color: #930;\n text-decoration: underline;\n}\n.kiss_bench small {\n font-family: arial, sans-serif;\n color: #a60;\n float: right;\n margin-left: 8px;\n position: relative;\n text-align: right;\n white-space: nowrap;\n}\n</style>\n"
html += @_benchmarks.map do |item|
start_link = context_link(item[:start_context])
end_link = context_link(item[:end_context])
"<div class=\"kiss_bench\">\n<small style=\"line-height: 105%; display: block; top: -4px\">kiss bench started at \#{start_link}<br/>ended at \#{end_link || 'request completion'}</small>\n<tt><b>\#{(item[:label] || 'unlabeled bench').to_s.gsub(/\\</, '<')} - duration: \#{sprintf(\"%0.3f\", item[:end_time].to_f - item[:start_time].to_f)} s</b></tt>\n</div>\n"
end.join
document.prepend_html(html, 'body')
end
|