Sha256: ac28963fdc57e87f721169589b8a7d56a453dddda1254054516a36a15611c7cc
Contents?: true
Size: 1.74 KB
Versions: 14
Compression:
Stored size: 1.74 KB
Contents
class Kiss # Generates HTML reports on exceptions raised from the app, # showing the backtrace with clickable stack frames with # TextMate links to source files, plus login hash, last SQL, # GET/POST params, cookies, and Rack environment variables. module Bench 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 def context_link(context) return nil unless context filename, line, method = context.split(/:/) textmate_url = "txmt://open?url=file://" + (Kiss.absolute_path(filename).html_escape) + '&line=' + line %Q(<a href="#{textmate_url}">#{filename}:#{line}</a> #{method}) end end end
Version data entries
14 entries across 14 versions & 1 rubygems