-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add benchee_html reporter for Benchee * Prepare to receive more benchmark files * Add example of bench file * Improve benchmark files and add new ones
- Loading branch information
Showing
8 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
inputs: [ | ||
"lib/**/*.{ex,exs}", | ||
"test/**/*.{ex,exs}", | ||
"benchs/*.exs", | ||
"mix.exs" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ erl_crash.dump | |
/priv/plts/*.plt | ||
/priv/plts/*.plt.hash | ||
/benchs/*.html | ||
/benchs/assets | ||
/benchs/results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
tag = | ||
case System.cmd("git", ["describe", "--tags"]) do | ||
{reference, 0} -> | ||
String.trim_trailing(reference) | ||
|
||
{error, _other} -> | ||
IO.puts("cannot get human readable name from git: #{inspect(error)}") | ||
"unknown" | ||
end | ||
|
||
IO.puts("tag in use for this benchmark is: #{tag}") | ||
|
||
read_file = fn name -> | ||
__ENV__.file | ||
|> Path.dirname() | ||
|> Path.join(name) | ||
|> File.read!() | ||
|> Floki.parse_document!() | ||
end | ||
|
||
inputs = %{ | ||
"big" => read_file.("big.html"), | ||
"medium" => read_file.("medium.html"), | ||
"small" => read_file.("small.html") | ||
} | ||
|
||
Benchee.run( | ||
%{ | ||
"class" => fn doc -> Floki.find(doc, ".class-mw-redirect") end, | ||
"class multiple" => fn doc -> Floki.find(doc, ".class-mw-redirect, .reference") end, | ||
"tag name (type)" => fn doc -> Floki.find(doc, "a") end, | ||
"id" => fn doc -> Floki.find(doc, "#cite_note-15") end | ||
}, | ||
time: 10, | ||
inputs: inputs, | ||
save: [path: "benchs/results/finder-#{tag}.benchee", tag: tag], | ||
memory_time: 2 | ||
) | ||
|
||
results = Path.wildcard("benchs/results/finder-*.benchee") | ||
|
||
if Enum.count(results) > 1 and function_exported?(Benchee, :report, 1) do | ||
html_path = "benchs/results/finder.html" | ||
|
||
Benchee.report( | ||
load: results, | ||
formatters: [ | ||
Benchee.Formatters.Console, | ||
{Benchee.Formatters.HTML, file: html_path, auto_open: true} | ||
] | ||
) | ||
|
||
IO.puts("open the HTML version in: #{html_path}") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
tag = | ||
case System.cmd("git", ["describe", "--tags"]) do | ||
{reference, 0} -> | ||
String.trim_trailing(reference) | ||
|
||
{error, _other} -> | ||
IO.puts("cannot get human readable name from git: #{inspect(error)}") | ||
"unknown" | ||
end | ||
|
||
IO.puts("tag in use for this benchmark is: #{tag}") | ||
|
||
read_file = fn name -> | ||
__ENV__.file | ||
|> Path.dirname() | ||
|> Path.join(name) | ||
|> File.read!() | ||
|> Floki.parse_document!() | ||
end | ||
|
||
inputs = %{ | ||
"big" => read_file.("big.html"), | ||
"medium" => read_file.("medium.html"), | ||
"small" => read_file.("small.html") | ||
} | ||
|
||
Benchee.run( | ||
%{ | ||
"bench" => fn doc -> Floki.raw_html(doc, pretty: true) end | ||
}, | ||
time: 10, | ||
inputs: inputs, | ||
save: [path: "benchs/results/raw-html-#{tag}.benchee", tag: tag], | ||
memory_time: 2 | ||
) | ||
|
||
results = Path.wildcard("benchs/results/raw-html-*.benchee") | ||
|
||
if Enum.count(results) > 1 and function_exported?(Benchee, :report, 1) do | ||
html_path = "benchs/results/raw-html.html" | ||
|
||
Benchee.report( | ||
load: results, | ||
formatters: [ | ||
Benchee.Formatters.Console, | ||
{Benchee.Formatters.HTML, file: html_path, auto_open: true} | ||
] | ||
) | ||
|
||
IO.puts("open the HTML version in: #{html_path}") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters