aboutsummaryrefslogtreecommitdiff
path: root/lib/mix/tasks
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2020-04-01 17:05:09 +0000
committerfeld <feld@feld.me>2020-04-01 17:05:09 +0000
commitef7d2b0f11a9bf74e982b73ae4cec632f93fbebc (patch)
tree2058bf1189b7a7ba12b1a160c27a9e92f3fa28bb /lib/mix/tasks
parentbfec45bf740f9fcfcea92bbded6bd2c146dc64c1 (diff)
parent1fcdcb12a717fa3dbd54a5c3778bd216df6449ad (diff)
downloadpleroma-ef7d2b0f11a9bf74e982b73ae4cec632f93fbebc.tar.gz
Merge branch 'gun' into 'develop'
Gun adapter Closes #945 See merge request pleroma/pleroma!1861
Diffstat (limited to 'lib/mix/tasks')
-rw-r--r--lib/mix/tasks/pleroma/benchmark.ex39
-rw-r--r--lib/mix/tasks/pleroma/emoji.ex9
2 files changed, 43 insertions, 5 deletions
diff --git a/lib/mix/tasks/pleroma/benchmark.ex b/lib/mix/tasks/pleroma/benchmark.ex
index a4885b70c..dd2b9c8f2 100644
--- a/lib/mix/tasks/pleroma/benchmark.ex
+++ b/lib/mix/tasks/pleroma/benchmark.ex
@@ -74,4 +74,43 @@ defmodule Mix.Tasks.Pleroma.Benchmark do
inputs: inputs
)
end
+
+ def run(["adapters"]) do
+ start_pleroma()
+
+ :ok =
+ Pleroma.Gun.Conn.open(
+ "https://httpbin.org/stream-bytes/1500",
+ :gun_connections
+ )
+
+ Process.sleep(1_500)
+
+ Benchee.run(
+ %{
+ "Without conn and without pool" => fn ->
+ {:ok, %Tesla.Env{}} =
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
+ adapter: [pool: :no_pool, receive_conn: false]
+ )
+ end,
+ "Without conn and with pool" => fn ->
+ {:ok, %Tesla.Env{}} =
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
+ adapter: [receive_conn: false]
+ )
+ end,
+ "With reused conn and without pool" => fn ->
+ {:ok, %Tesla.Env{}} =
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
+ adapter: [pool: :no_pool]
+ )
+ end,
+ "With reused conn and with pool" => fn ->
+ {:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")
+ end
+ },
+ parallel: 10
+ )
+ end
end
diff --git a/lib/mix/tasks/pleroma/emoji.ex b/lib/mix/tasks/pleroma/emoji.ex
index 2b03a3009..429d763c7 100644
--- a/lib/mix/tasks/pleroma/emoji.ex
+++ b/lib/mix/tasks/pleroma/emoji.ex
@@ -4,13 +4,13 @@
defmodule Mix.Tasks.Pleroma.Emoji do
use Mix.Task
+ import Mix.Pleroma
@shortdoc "Manages emoji packs"
@moduledoc File.read!("docs/administration/CLI_tasks/emoji.md")
def run(["ls-packs" | args]) do
- Mix.Pleroma.start_pleroma()
- Application.ensure_all_started(:hackney)
+ start_pleroma()
{options, [], []} = parse_global_opts(args)
@@ -36,8 +36,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
end
def run(["get-packs" | args]) do
- Mix.Pleroma.start_pleroma()
- Application.ensure_all_started(:hackney)
+ start_pleroma()
{options, pack_names, []} = parse_global_opts(args)
@@ -135,7 +134,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
end
def run(["gen-pack", src]) do
- Application.ensure_all_started(:hackney)
+ start_pleroma()
proposed_name = Path.basename(src) |> Path.rootname()
name = String.trim(IO.gets("Pack name [#{proposed_name}]: "))