Defect #43737 » bench_textile.rb
| 1 |
require 'benchmark' |
|---|---|
| 2 |
|
| 3 |
Setting.text_formatting = 'textile' |
| 4 |
Setting.cache_formatted_text = 0 |
| 5 |
|
| 6 |
text = <<~TXT |
| 7 |
|_. a |_. b |
|
| 8 |
| 1 | 2 |
|
| 9 |
|
| 10 |
<pre><code class="ruby">
|
| 11 |
def hello
|
| 12 |
puts 'hi'
|
| 13 |
end
|
| 14 |
</code></pre>
|
| 15 |
TXT
|
| 16 |
|
| 17 |
iter = (ENV['ITER'] || '20').to_i |
| 18 |
mult = (ENV['MULT'] || '5').to_i |
| 19 |
text = Array.new(mult, text).join("\n") |
| 20 |
|
| 21 |
puts "ruby=#{RUBY_VERSION} iter=#{iter} mult=#{mult}" |
| 22 |
|
| 23 |
# Warm up to avoid measuring one-time initialization costs.
|
| 24 |
2.times { Redmine::WikiFormatting.to_html('textile', text) } |
| 25 |
|
| 26 |
full = Benchmark.realtime do |
| 27 |
iter.times { Redmine::WikiFormatting.to_html('textile', text) } |
| 28 |
end
|
| 29 |
|
| 30 |
puts "full_ms=#{(full*1000).round(2)} avg_full=#{((full/iter)*1000).round(2)}" |
- « Previous
- 1
- 2
- Next »