discourse/script/benchmarks/markdown/bench.rb

103 lines
3.7 KiB
Ruby
Raw Normal View History

require 'benchmark/ips'
require File.expand_path('../../../../config/environment', __FILE__)
tests = [
["tiny post", "**hello**"],
["giant post", File.read("giant_post.md")],
["most features", File.read("most_features.md")],
["lots of mentions", File.read("lots_of_mentions.md")]
]
PrettyText.cook("")
PrettyText.v8.eval("window.commonmark = window.markdownit('commonmark')")
# Benchmark.ips do |x|
# x.report("markdown") do
# PrettyText.markdown("x")
# end
#
# x.report("cook") do
# PrettyText.cook("y")
# end
# end
#
# exit
Benchmark.ips do |x|
[true,false].each do |sanitize|
2017-07-19 00:31:32 +08:00
tests.each do |test, text|
x.report("#{test} sanitize: #{sanitize}") do
PrettyText.markdown(text, sanitize: sanitize)
end
end
end
tests.each do |test, text|
x.report("markdown it no extensions commonmark #{test}") do
PrettyText.v8.eval("window.commonmark.render(#{text.inspect})")
end
end
end
2017-07-19 00:31:32 +08:00
2017-07-26 22:59:32 +08:00
# 27-07-2017 - Sam's NUC
#
# v8 5.7
#
#
2017-07-19 00:31:32 +08:00
# tiny post sanitize: true
2017-07-26 22:59:32 +08:00
# 160.678 (±19.9%) i/s - 760.000 in 5.005630s
2017-07-19 00:31:32 +08:00
# giant post sanitize: true
2017-07-26 22:59:32 +08:00
# 132.195 (±14.4%) i/s - 649.000 in 5.042695s
2017-07-19 00:31:32 +08:00
# most features sanitize: true
2017-07-26 22:59:32 +08:00
# 56.205 (± 8.9%) i/s - 280.000 in 5.038138s
2017-07-19 00:31:32 +08:00
# lots of mentions sanitize: true
2017-07-26 22:59:32 +08:00
# 0.318 (± 0.0%) i/s - 2.000 in 6.293644s
2017-07-19 00:31:32 +08:00
# tiny post sanitize: false
2017-07-26 22:59:32 +08:00
# 404.304 (±20.8%) i/s - 1.920k in 5.019903s
2017-07-19 00:31:32 +08:00
# giant post sanitize: false
2017-07-26 22:59:32 +08:00
# 327.721 (±11.9%) i/s - 1.624k in 5.033749s
2017-07-19 00:31:32 +08:00
# most features sanitize: false
2017-07-26 22:59:32 +08:00
# 76.649 (±10.4%) i/s - 385.000 in 5.085552s
2017-07-19 00:31:32 +08:00
# lots of mentions sanitize: false
2017-07-26 22:59:32 +08:00
# 0.306 (± 0.0%) i/s - 2.000 in 6.525968s
2017-07-19 00:31:32 +08:00
# markdown it no extensions commonmark tiny post
2017-07-26 22:59:32 +08:00
# 5.871k (±19.1%) i/s - 28.544k in 5.073585s
2017-07-19 00:31:32 +08:00
# markdown it no extensions commonmark giant post
2017-07-26 22:59:32 +08:00
# 1.006k (±12.5%) i/s - 4.960k in 5.041623s
2017-07-19 00:31:32 +08:00
# markdown it no extensions commonmark most features
2017-07-26 22:59:32 +08:00
# 1.447k (± 8.9%) i/s - 7.205k in 5.029094s
2017-07-19 00:31:32 +08:00
# markdown it no extensions commonmark lots of mentions
2017-07-26 22:59:32 +08:00
# 1.962k (± 8.3%) i/s - 9.850k in 5.061684s
#
2017-07-19 00:31:32 +08:00
#
2017-07-26 22:59:32 +08:00
# v8 5.9
#
#
# tiny post sanitize: true
# 156.179 (±16.0%) i/s - 765.000 in 5.059401s
# giant post sanitize: true
# 129.972 (±10.8%) i/s - 650.000 in 5.071824s
# most features sanitize: true
# 54.960 (± 9.1%) i/s - 275.000 in 5.051284s
# lots of mentions sanitize: true
# 0.321 (± 0.0%) i/s - 2.000 in 6.251009s
# tiny post sanitize: false
# 431.159 (±10.4%) i/s - 2.166k in 5.085303s
# giant post sanitize: false
# 300.236 (±11.7%) i/s - 1.479k in 5.029557s
# most features sanitize: false
# 73.808 (±10.8%) i/s - 371.000 in 5.092310s
# lots of mentions sanitize: false
# 0.297 (± 0.0%) i/s - 2.000 in 6.729708s
# markdown it no extensions commonmark tiny post
# 6.421k (±13.0%) i/s - 32.012k in 5.084672s
# markdown it no extensions commonmark giant post
# 901.622 (± 9.2%) i/s - 4.452k in 5.016748s
# markdown it no extensions commonmark most features
# 1.410k (± 6.5%) i/s - 7.112k in 5.070053s
# markdown it no extensions commonmark lots of mentions
# 1.934k (± 6.4%) i/s - 9.672k in 5.025858s