aboutsummaryrefslogtreecommitdiff
path: root/lib/mix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mix')
-rw-r--r--lib/mix/pleroma.ex1
-rw-r--r--lib/mix/tasks/pleroma/benchmark.ex39
-rw-r--r--lib/mix/tasks/pleroma/emoji.ex9
3 files changed, 44 insertions, 5 deletions
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex
index 3ad6edbfb..4dfcc32e7 100644
--- a/lib/mix/pleroma.ex
+++ b/lib/mix/pleroma.ex
@@ -5,6 +5,7 @@
defmodule Mix.Pleroma do
@doc "Common functions to be reused in mix tasks"
def start_pleroma do
+ Mix.Task.run("app.start")
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
if Pleroma.Config.get(:env) != :test do
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}]: "))