Commit bb0a1c96 authored by Ariadne Conill's avatar Ariadne Conill

rework benchmarks

parent 1220d6ec
defmodule BasicHtmlBench do
use Benchfella
setup_all do
html = File.read!("bench/w3c_html5.html")
context = {html, Myhtmlex.open(html)}
{:ok, context}
end
bench "decode" do
{html, _} = bench_context
Myhtmlex.decode(html)
:fast_html.decode(html)
end
bench "decode w/ html_atoms" do
{html, _} = bench_context
Myhtmlex.decode(html, format: [:html_atoms])
:fast_html.decode(html, format: [:html_atoms])
end
bench "decode w/ nil_self_closing" do
{html, _} = bench_context
Myhtmlex.decode(html, format: [:nil_self_closing])
:fast_html.decode(html, format: [:nil_self_closing])
end
bench "decode w/ html_atoms, nil_self_closing" do
{html, _} = bench_context
Myhtmlex.decode(html, format: [:html_atoms, :nil_self_closing])
end
bench "decode_tree" do
{_, ref} = bench_context
Myhtmlex.decode_tree(ref)
:fast_html.decode(html, format: [:html_atoms, :nil_self_closing])
end
bench "decode_tree w/ html_atoms" do
{_, ref} = bench_context
Myhtmlex.decode_tree(ref, format: [:html_atoms])
end
end
......@@ -14,17 +14,17 @@ defmodule CnodeFileSizesBench do
bench "github_trending_js.html 341k" do
{ref, _, _} = bench_context
Myhtmlex.Safe.decode(ref)
:fast_html.decode(ref)
end
bench "w3c_html5.html 131k" do
{_, ref, _} = bench_context
Myhtmlex.Safe.decode(ref)
:fast_html.decode(ref)
end
bench "wikipedia_hyperlink.html 97k" do
{_, _, ref} = bench_context
Myhtmlex.Safe.decode(ref)
:fast_html.decode(ref)
end
end
......
defmodule FileSizesBench do
use Benchfella
setup_all do
refs = {
File.read!("bench/github_trending_js.html") |> Myhtmlex.open,
File.read!("bench/w3c_html5.html") |> Myhtmlex.open,
File.read!("bench/wikipedia_hyperlink.html") |> Myhtmlex.open
}
{:ok, refs}
end
bench "github_trending_js.html 341k" do
{ref, _, _} = bench_context
Myhtmlex.decode_tree(ref)
end
bench "w3c_html5.html 131k" do
{_, ref, _} = bench_context
Myhtmlex.decode_tree(ref)
end
bench "wikipedia_hyperlink.html 97k" do
{_, _, ref} = bench_context
Myhtmlex.decode_tree(ref)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment