Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F115601
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
index 7066211..a9fb488 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,25 +1,30 @@
# The directory Mix will write compiled artifacts to.
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
# Ignore package tarball (built via "mix hex.build").
exile-*.tar
-.dir-locals.el
\ No newline at end of file
+.dir-locals.el
+
+# Bench
+/bench/_build/
+/bench/deps/
+/bench/output/
diff --git a/bench/io.exs b/bench/io.exs
new file mode 100644
index 0000000..24b1a13
--- /dev/null
+++ b/bench/io.exs
@@ -0,0 +1,88 @@
+defmodule ExileBench.Read do
+ @size 1000
+ @chunk_size 1024 * 4
+ @data :crypto.strong_rand_bytes(@chunk_size)
+
+ defp exile_read_loop(s, @size), do: Exile.Process.close_stdin(s)
+
+ defp exile_read_loop(s, count) do
+ :ok = Exile.Process.write(s, @data)
+
+ case Exile.Process.read(s, @chunk_size) do
+ {:ok, _data} -> exile_read_loop(s, count + 1)
+ {:eof, _} -> :ok
+ end
+ end
+
+ def exile do
+ {:ok, s} = Exile.Process.start_link(["cat"])
+ :ok = exile_read_loop(s, 0)
+ Exile.Process.stop(s)
+ end
+
+ # port
+ defp port_read(_port, 0), do: :ok
+ defp port_read(port, size) do
+ receive do
+ {^port, {:data, data}} -> port_read(port, size - IO.iodata_length(data))
+ end
+ end
+
+ defp port_loop(_port, @size), do: :ok
+
+ defp port_loop(port, count) do
+ true = Port.command(port, @data)
+ :ok = port_read(port, @chunk_size)
+ port_loop(port, count + 1)
+ end
+
+ def port do
+ cat = :os.find_executable('cat')
+
+ port =
+ Port.open({:spawn_executable, cat}, [
+ :use_stdio,
+ :exit_status,
+ :binary
+ ])
+
+ port_loop(port, 0)
+ Port.close(port)
+ end
+
+
+ # ex_cmd
+ defp ex_cmd_read_loop(s, @size), do: ExCmd.Process.close_stdin(s)
+
+ defp ex_cmd_read_loop(s, count) do
+ :ok = ExCmd.Process.write(s, @data)
+
+ case ExCmd.Process.read(s, @chunk_size) do
+ {:ok, _data} -> ex_cmd_read_loop(s, count + 1)
+ :eof -> :ok
+ end
+ end
+
+ def ex_cmd do
+ {:ok, s} = ExCmd.Process.start_link(["cat"])
+ :ok = ex_cmd_read_loop(s, 0)
+ ExCmd.Process.stop(s)
+ end
+end
+
+read_jobs = %{
+ "Exile" => fn -> ExileBench.Read.exile() end,
+ "Port" => fn -> ExileBench.Read.port() end,
+ "ExCmd" => fn -> ExileBench.Read.ex_cmd() end
+}
+
+Benchee.run(read_jobs,
+ # parallel: 4,
+ warmup: 5,
+ time: 30,
+ memory_time: 1,
+ formatters: [
+ {Benchee.Formatters.HTML, file: Path.expand("output/read.html", __DIR__)},
+ Benchee.Formatters.Console
+ ]
+)
diff --git a/bench/mix.exs b/bench/mix.exs
new file mode 100644
index 0000000..5b4980a
--- /dev/null
+++ b/bench/mix.exs
@@ -0,0 +1,30 @@
+defmodule ExileBench.MixProject do
+ use Mix.Project
+
+ def project do
+ [
+ app: :exile_bench,
+ version: "0.1.0",
+ elixir: "~> 1.7",
+ start_permanent: Mix.env() == :prod,
+ deps: deps(),
+ aliases: aliases()
+ ]
+ end
+
+ defp aliases() do
+ [
+ "bench.io": ["run io.exs"]
+ ]
+ end
+
+ # Run "mix help deps" to learn about dependencies.
+ defp deps do
+ [
+ {:benchee, "~> 1.0"},
+ {:benchee_html, "~> 1.0"},
+ {:exile, "~> 0.1", path: "../", override: true},
+ {:ex_cmd, "~> 0.4.1"}
+ ]
+ end
+end
diff --git a/bench/mix.lock b/bench/mix.lock
new file mode 100644
index 0000000..0d1e6a1
--- /dev/null
+++ b/bench/mix.lock
@@ -0,0 +1,10 @@
+%{
+ "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"},
+ "benchee_html": {:hex, :benchee_html, "1.0.0", "5b4d24effebd060f466fb460ec06576e7b34a00fc26b234fe4f12c4f05c95947", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 1.0", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm", "5280af9aac432ff5ca4216d03e8a93f32209510e925b60e7f27c33796f69e699"},
+ "benchee_json": {:hex, :benchee_json, "1.0.0", "cc661f4454d5995c08fe10dd1f2f72f229c8f0fb1c96f6b327a8c8fc96a91fe5", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "da05d813f9123505f870344d68fb7c86a4f0f9074df7d7b7e2bb011a63ec231c"},
+ "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
+ "elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
+ "ex_cmd": {:hex, :ex_cmd, "0.4.1", "e7d194abdd8c98fd936d760d2a72e42075398a915902bcec74281927b5321bd5", [:mix], [{:gen_state_machine, "~> 2.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}], "hexpm", "d58dde62094419351c79d3215325300128f6895c643792d501adcd5cf507ef13"},
+ "gen_state_machine": {:hex, :gen_state_machine, "2.1.0", "a38b0e53fad812d29ec149f0d354da5d1bc0d7222c3711f3a0bd5aa608b42992", [:mix], [], "hexpm", "ae367038808db25cee2f2c4b8d0531522ea587c4995eb6f96ee73410a60fa06b"},
+ "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 28, 8:17 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40983
Default Alt Text
(5 KB)
Attached To
Mode
R14 exile
Attached
Detach File
Event Timeline
Log In to Comment