diff options
Diffstat (limited to 'test/soak.exs')
-rw-r--r-- | test/soak.exs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/soak.exs b/test/soak.exs new file mode 100644 index 0000000..ab366f0 --- /dev/null +++ b/test/soak.exs @@ -0,0 +1,35 @@ +defmodule Soak do + @moduledoc """ + Run with a list of files to inspect: + + find /usr/share/ -name *png | xargs mix run test/soak.exs + """ + + def perform_infinite([]), do: false + + def perform_infinite(paths) do + {:ok, pid} = + GenMagic.ApprenticeServer.start_link(database_patterns: ["/usr/local/share/misc/*.mgc"]) + + perform_infinite(paths, [], pid, 0) + end + + defp perform_infinite([], done, pid, count) do + perform_infinite(done, [], pid, count) + end + + defp perform_infinite([path | paths], done, pid, count) do + if rem(count, 1000) == 0, do: IO.puts(Integer.to_string(count)) + + {:ok, [mime_type: _, encoding: _, content: _]} = GenServer.call(pid, {:file, path}) + perform_infinite(paths, [path | done], pid, count + 1) + end +end + +# Run with a list of files to inspect +# +# find /usr/share/ -name *png | xargs mix run test/soak.exs + +System.argv() +|> Enum.filter(&File.exists?/1) +|> Soak.perform_infinite() |