correct bench code

This commit is contained in:
Sam 2017-07-18 12:31:32 -04:00
parent b92e181390
commit 7c7f22565c
1 changed files with 33 additions and 14 deletions

View File

@ -9,7 +9,6 @@ tests = [
["lots of mentions", File.read("lots_of_mentions.md")] ["lots of mentions", File.read("lots_of_mentions.md")]
] ]
SiteSetting.enable_experimental_markdown_it = true
PrettyText.cook("") PrettyText.cook("")
PrettyText.v8.eval("window.commonmark = window.markdownit('commonmark')") PrettyText.v8.eval("window.commonmark = window.markdownit('commonmark')")
@ -27,19 +26,9 @@ PrettyText.v8.eval("window.commonmark = window.markdownit('commonmark')")
Benchmark.ips do |x| Benchmark.ips do |x|
[true,false].each do |sanitize| [true,false].each do |sanitize|
{ tests.each do |test, text|
"markdown js" => x.report("#{test} sanitize: #{sanitize}") do
lambda{SiteSetting.enable_experimental_markdown_it = false}, PrettyText.markdown(text, sanitize: sanitize)
"markdown it" =>
lambda{SiteSetting.enable_experimental_markdown_it = true}
}.each do |name, before|
before.call
tests.each do |test, text|
x.report("#{name} #{test} sanitize: #{sanitize}") do
PrettyText.markdown(text, sanitize: sanitize)
end
end end
end end
end end
@ -52,3 +41,33 @@ Benchmark.ips do |x|
end end
end end
# 18-07-2017 - Sam's NUC
# Calculating -------------------------------------
# tiny post sanitize: true
# 162.766 (±13.5%) i/s - 812.000 in 5.101429s
# giant post sanitize: true
# 133.957 (±11.2%) i/s - 663.000 in 5.029386s
# most features sanitize: true
# 55.319 (±10.8%) i/s - 276.000 in 5.054290s
# lots of mentions sanitize: true
# 0.313 (± 0.0%) i/s - 2.000 in 6.394343s
# tiny post sanitize: false
# 456.209 (±13.6%) i/s - 2.288k in 5.117314s
# giant post sanitize: false
# 331.357 (±10.9%) i/s - 1.650k in 5.046322s
# most features sanitize: false
# 77.038 (±10.4%) i/s - 385.000 in 5.055062s
# lots of mentions sanitize: false
# 0.312 (± 0.0%) i/s - 2.000 in 6.430657s
# markdown it no extensions commonmark tiny post
# 6.916k (± 5.5%) i/s - 34.540k in 5.010354s
# markdown it no extensions commonmark giant post
# 1.044k (± 9.3%) i/s - 5.247k in 5.090534s
# markdown it no extensions commonmark most features
# 1.457k (± 5.0%) i/s - 7.314k in 5.034401s
# markdown it no extensions commonmark lots of mentions
# 2.004k (± 5.2%) i/s - 10.192k in 5.100657s
# sam@ubuntu markdown %
#