Sha256: 5cf6451bc300a4733952774f9ed6a10f577b09fd52859db1c52e7795e9ac35da
Contents?: true
Size: 844 Bytes
Versions: 2
Compression:
Stored size: 844 Bytes
Contents
module BenchmarkToJs module ViewHelpers def benchmark_to_js(name = 'block', &block) if BenchmarkToJs.configuration.run? ret = '' time = Benchmark.ms {ret = capture(&block)} message = if BenchmarkToJs.configuration.pretty color = if time >= BenchmarkToJs.configuration.red_threshold 'red' elsif time >= BenchmarkToJs.configuration.orange_threshold 'darkorange' else 'green' end %Q("%c #{escape_javascript(name)} %c ran in %c#{time.round(5)}ms", 'background: #222; color: #bada55', '', 'color:#{color}') else %Q("'#{escape_javascript(name)}' ran in #{time.round(5)}ms") end ret + javascript_tag(%Q(console.log(#{message}))) else capture(&block) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
benchmark_to_js-0.2.0 | lib/benchmark_to_js/view_helpers.rb |
benchmark_to_js-0.1.0 | lib/benchmark_to_js/view_helpers.rb |