1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.Benchmark do
14 Pleroma.Activity.search(nil, "cofe")
24 %{"type" => "Create", "tag" => "cofe"}
25 |> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
30 def run(["render_timeline", nickname | _] = args) do
32 user = Pleroma.User.get_by_nickname(nickname)
36 |> Map.put("type", ["Create", "Announce"])
37 |> Map.put("blocking_user", user)
38 |> Map.put("muting_user", user)
39 |> Map.put("user", user)
40 |> Map.put("limit", 4096)
41 |> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
45 "1 activity" => Enum.take_random(activities, 1),
46 "10 activities" => Enum.take_random(activities, 10),
47 "20 activities" => Enum.take_random(activities, 20),
48 "40 activities" => Enum.take_random(activities, 40),
49 "80 activities" => Enum.take_random(activities, 80)
53 if Enum.at(args, 2) == "extended" do
55 "200 activities" => Enum.take_random(activities, 200),
56 "500 activities" => Enum.take_random(activities, 500),
57 "2000 activities" => Enum.take_random(activities, 2000),
58 "4096 activities" => Enum.take_random(activities, 4096)
66 "Standart rendering" => fn activities ->
67 Pleroma.Web.MastodonAPI.StatusView.render("index.json", %{
68 activities: activities,
78 def run(["adapters"]) do
82 Pleroma.Gun.Conn.open(
83 "https://httpbin.org/stream-bytes/1500",
91 "Without conn and without pool" => fn ->
93 Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
98 "Without conn and with pool" => fn ->
100 Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], receive_conn: false)
102 "With reused conn and without pool" => fn ->
103 {:ok, %Tesla.Env{}} =
104 Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], pool: :no_pool)
106 "With reused conn and with pool" => fn ->
107 {:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")