Page MenuHomePhorge

No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/mix/tasks/fast_sanitize/html/document-medium.html b/bench_fixtures/document-medium.html
similarity index 100%
rename from lib/mix/tasks/fast_sanitize/html/document-medium.html
rename to bench_fixtures/document-medium.html
diff --git a/lib/mix/tasks/fast_sanitize/html/document-small.html b/bench_fixtures/document-small.html
similarity index 100%
rename from lib/mix/tasks/fast_sanitize/html/document-small.html
rename to bench_fixtures/document-small.html
diff --git a/lib/mix/tasks/fast_sanitize/html/fragment-large.html b/bench_fixtures/fragment-large.html
similarity index 100%
rename from lib/mix/tasks/fast_sanitize/html/fragment-large.html
rename to bench_fixtures/fragment-large.html
diff --git a/lib/mix/tasks/fast_sanitize/html/fragment-small.html b/bench_fixtures/fragment-small.html
similarity index 100%
rename from lib/mix/tasks/fast_sanitize/html/fragment-small.html
rename to bench_fixtures/fragment-small.html
diff --git a/lib/mix/tasks/fast_sanitize/bench.ex b/lib/mix/tasks/fast_sanitize/bench.ex
index e9d34a1..2f9d151 100644
--- a/lib/mix/tasks/fast_sanitize/bench.ex
+++ b/lib/mix/tasks/fast_sanitize/bench.ex
@@ -1,27 +1,29 @@
-defmodule Mix.Tasks.FastSanitize.Bench do
- @moduledoc "Benchmarking task."
+if Mix.env() == :bench do
+ defmodule Mix.Tasks.FastSanitize.Bench do
+ @moduledoc "Benchmarking task."
- use Mix.Task
+ use Mix.Task
- @input_dir "lib/mix/tasks/fast_sanitize/html"
+ @input_dir "bench_fixtures"
- def run(_) do
- Application.ensure_all_started(:fast_html)
+ def run(_) do
+ Application.ensure_all_started(:fast_html)
- inputs =
- Enum.reduce(File.ls!(@input_dir), %{}, fn input_name, acc ->
- input = File.read!(Path.join(@input_dir, input_name))
- Map.put(acc, input_name, input)
- end)
+ inputs =
+ Enum.reduce(File.ls!(@input_dir), %{}, fn input_name, acc ->
+ input = File.read!(Path.join(@input_dir, input_name))
+ Map.put(acc, input_name, input)
+ end)
- Benchee.run(
- %{
- "FastSanitize strip tags" => fn input -> FastSanitize.strip_tags(input) end,
- "HtmlSanitizeex strip tags" => fn input -> HtmlSanitizeEx.strip_tags(input) end,
- "FastSanitize basic html" => fn input -> FastSanitize.basic_html(input) end,
- "HtmlSanitizeex basic html" => fn input -> HtmlSanitizeEx.basic_html(input) end
- },
- inputs: inputs
- )
+ Benchee.run(
+ %{
+ "FastSanitize strip tags" => fn input -> FastSanitize.strip_tags(input) end,
+ "HtmlSanitizeex strip tags" => fn input -> HtmlSanitizeEx.strip_tags(input) end,
+ "FastSanitize basic html" => fn input -> FastSanitize.basic_html(input) end,
+ "HtmlSanitizeex basic html" => fn input -> HtmlSanitizeEx.basic_html(input) end
+ },
+ inputs: inputs
+ )
+ end
end
end
diff --git a/mix.exs b/mix.exs
index 9a7dfcc..14f8d00 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,49 +1,49 @@
defmodule FastSanitize.MixProject do
use Mix.Project
def project do
[
app: :fast_sanitize,
version: "0.1.2",
elixir: "~> 1.7",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
description: """
A module that provides performant and memory-efficient HTML sanitization.
Largely drop-in compatible with HtmlSanitizeEx.
"""
]
end
def package do
[
maintainers: ["Ariadne Conill"],
licenses: ["MIT"],
links: %{
"GitLab" => "https://git.pleroma.social/pleroma/fast_sanitize",
"Issues" => "https://git.pleroma.social/pleroma/fast_sanitize/issues"
}
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:plug, "~> 1.8"},
{:fast_html, "~> 0.99"},
{:credo, "~> 1.0.0", only: [:dev, :test], runtime: false},
- {:benchee, "~> 1.0", only: :dev},
- {:html_sanitize_ex, "~> 1.3.0-rc3", only: :dev},
+ {:benchee, "~> 1.0", only: :bench},
+ {:html_sanitize_ex, "~> 1.3.0-rc3", only: :bench},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.5", only: [:dev], runtime: false}
]
end
end

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 27, 2:52 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40672
Default Alt Text
(4 KB)

Event Timeline