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 = <<-EOT
<style>
.kiss_bench {
text-align: left;
padding: 3px 7px;
border: 1px solid #ec4;
border-top: 1px solid #fff4bb;
border-bottom: 1px solid #d91;
background-color: #ffe590;
font-size: 12px;
color: #101;
}
.kiss_bench a {
color: #930;
text-decoration: none;
}
.kiss_bench a:hover {
color: #930;
text-decoration: underline;
}
.kiss_bench small {
font-family: arial, sans-serif;
color: #a60;
float: right;
margin-left: 8px;
position: relative;
text-align: right;
white-space: nowrap;
}
</style>
EOT
html += @_benchmarks.map do |item|
start_link = context_link(item[:start_context])
end_link = context_link(item[:end_context])
<<-EOT
<div class="kiss_bench">
<small style="line-height: 105%; display: block; top: -4px">kiss bench started at #{start_link}<br/>ended at #{end_link || 'request completion'}</small>
<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>
</div>
EOT
end.join
document.prepend_html(html, 'body')
end
|