summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-06-04 21:33:16 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-06-04 21:36:26 +0400
commit317e2b8d6126d86eafb493fe6c3b7a29af65ee21 (patch)
tree539ba5d42509ecf63df3ddefcfd76fce27bc52fc /benchmarks
parentf5cb1f3616e9cb9430038697532eb49161937dec (diff)
Use atoms as keys in `ActivityPub.fetch_*` functions options
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/load_testing/fetcher.ex194
-rw-r--r--benchmarks/mix/tasks/pleroma/benchmarks/tags.ex16
2 files changed, 103 insertions, 107 deletions
diff --git a/benchmarks/load_testing/fetcher.ex b/benchmarks/load_testing/fetcher.ex
index 22a06e472..15fd06c3d 100644
--- a/benchmarks/load_testing/fetcher.ex
+++ b/benchmarks/load_testing/fetcher.ex
@@ -52,12 +52,12 @@ defmodule Pleroma.LoadTesting.Fetcher do
defp opts_for_home_timeline(user) do
%{
- "blocking_user" => user,
- "count" => "20",
- "muting_user" => user,
- "type" => ["Create", "Announce"],
- "user" => user,
- "with_muted" => "true"
+ blocking_user: user,
+ count: "20",
+ muting_user: user,
+ type: ["Create", "Announce"],
+ user: user,
+ with_muted: true
}
end
@@ -70,17 +70,17 @@ defmodule Pleroma.LoadTesting.Fetcher do
ActivityPub.fetch_activities(recipients, opts) |> Enum.reverse() |> List.last()
second_page_last =
- ActivityPub.fetch_activities(recipients, Map.put(opts, "max_id", first_page_last.id))
+ ActivityPub.fetch_activities(recipients, Map.put(opts, :max_id, first_page_last.id))
|> Enum.reverse()
|> List.last()
third_page_last =
- ActivityPub.fetch_activities(recipients, Map.put(opts, "max_id", second_page_last.id))
+ ActivityPub.fetch_activities(recipients, Map.put(opts, :max_id, second_page_last.id))
|> Enum.reverse()
|> List.last()
forth_page_last =
- ActivityPub.fetch_activities(recipients, Map.put(opts, "max_id", third_page_last.id))
+ ActivityPub.fetch_activities(recipients, Map.put(opts, :max_id, third_page_last.id))
|> Enum.reverse()
|> List.last()
@@ -90,19 +90,19 @@ defmodule Pleroma.LoadTesting.Fetcher do
},
inputs: %{
"1 page" => opts,
- "2 page" => Map.put(opts, "max_id", first_page_last.id),
- "3 page" => Map.put(opts, "max_id", second_page_last.id),
- "4 page" => Map.put(opts, "max_id", third_page_last.id),
- "5 page" => Map.put(opts, "max_id", forth_page_last.id),
- "1 page only media" => Map.put(opts, "only_media", "true"),
+ "2 page" => Map.put(opts, :max_id, first_page_last.id),
+ "3 page" => Map.put(opts, :max_id, second_page_last.id),
+ "4 page" => Map.put(opts, :max_id, third_page_last.id),
+ "5 page" => Map.put(opts, :max_id, forth_page_last.id),
+ "1 page only media" => Map.put(opts, :only_media, true),
"2 page only media" =>
- Map.put(opts, "max_id", first_page_last.id) |> Map.put("only_media", "true"),
+ Map.put(opts, :max_id, first_page_last.id) |> Map.put(:only_media, true),
"3 page only media" =>
- Map.put(opts, "max_id", second_page_last.id) |> Map.put("only_media", "true"),
+ Map.put(opts, :max_id, second_page_last.id) |> Map.put(:only_media, true),
"4 page only media" =>
- Map.put(opts, "max_id", third_page_last.id) |> Map.put("only_media", "true"),
+ Map.put(opts, :max_id, third_page_last.id) |> Map.put(:only_media, true),
"5 page only media" =>
- Map.put(opts, "max_id", forth_page_last.id) |> Map.put("only_media", "true")
+ Map.put(opts, :max_id, forth_page_last.id) |> Map.put(:only_media, true)
},
formatters: formatters()
)
@@ -110,12 +110,12 @@ defmodule Pleroma.LoadTesting.Fetcher do
defp opts_for_direct_timeline(user) do
%{
- :visibility => "direct",
- "blocking_user" => user,
- "count" => "20",
- "type" => "Create",
- "user" => user,
- "with_muted" => "true"
+ visibility: "direct",
+ blocking_user: user,
+ count: "20",
+ type: "Create",
+ user: user,
+ with_muted: true
}
end
@@ -130,7 +130,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
|> Pagination.fetch_paginated(opts)
|> List.last()
- opts2 = Map.put(opts, "max_id", first_page_last.id)
+ opts2 = Map.put(opts, :max_id, first_page_last.id)
second_page_last =
recipients
@@ -138,7 +138,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
|> Pagination.fetch_paginated(opts2)
|> List.last()
- opts3 = Map.put(opts, "max_id", second_page_last.id)
+ opts3 = Map.put(opts, :max_id, second_page_last.id)
third_page_last =
recipients
@@ -146,7 +146,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
|> Pagination.fetch_paginated(opts3)
|> List.last()
- opts4 = Map.put(opts, "max_id", third_page_last.id)
+ opts4 = Map.put(opts, :max_id, third_page_last.id)
forth_page_last =
recipients
@@ -165,7 +165,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
"2 page" => opts2,
"3 page" => opts3,
"4 page" => opts4,
- "5 page" => Map.put(opts4, "max_id", forth_page_last.id)
+ "5 page" => Map.put(opts4, :max_id, forth_page_last.id)
},
formatters: formatters()
)
@@ -173,34 +173,34 @@ defmodule Pleroma.LoadTesting.Fetcher do
defp opts_for_public_timeline(user) do
%{
- "type" => ["Create", "Announce"],
- "local_only" => false,
- "blocking_user" => user,
- "muting_user" => user
+ type: ["Create", "Announce"],
+ local_only: false,
+ blocking_user: user,
+ muting_user: user
}
end
defp opts_for_public_timeline(user, :local) do
%{
- "type" => ["Create", "Announce"],
- "local_only" => true,
- "blocking_user" => user,
- "muting_user" => user
+ type: ["Create", "Announce"],
+ local_only: true,
+ blocking_user: user,
+ muting_user: user
}
end
defp opts_for_public_timeline(user, :tag) do
%{
- "blocking_user" => user,
- "count" => "20",
- "local_only" => nil,
- "muting_user" => user,
- "tag" => ["tag"],
- "tag_all" => [],
- "tag_reject" => [],
- "type" => "Create",
- "user" => user,
- "with_muted" => "true"
+ blocking_user: user,
+ count: "20",
+ local_only: nil,
+ muting_user: user,
+ tag: ["tag"],
+ tag_all: [],
+ tag_reject: [],
+ type: "Create",
+ user: user,
+ with_muted: true
}
end
@@ -223,7 +223,7 @@ defmodule Pleroma.LoadTesting.Fetcher do
end
defp fetch_public_timeline(user, :only_media) do
- opts = opts_for_public_timeline(user) |> Map.put("only_media", "true")
+ opts = opts_for_public_timeline(user) |> Map.put(:only_media, true)
fetch_public_timeline(opts, "public timeline only media")
end
@@ -245,15 +245,13 @@ defmodule Pleroma.LoadTesting.Fetcher do
user = User.get_by_id(user.id)
- opts = Map.put(opts, "blocking_user", user)
+ opts = Map.put(opts, :blocking_user, user)
- Benchee.run(
- %{
- "public timeline with user block" => fn ->
- ActivityPub.fetch_public_activities(opts)
- end
- },
- )
+ Benchee.run(%{
+ "public timeline with user block" => fn ->
+ ActivityPub.fetch_public_activities(opts)
+ end
+ })
domains =
Enum.reduce(remote_non_friends, [], fn non_friend, domains ->
@@ -269,30 +267,28 @@ defmodule Pleroma.LoadTesting.Fetcher do
end)
user = User.get_by_id(user.id)
- opts = Map.put(opts, "blocking_user", user)
+ opts = Map.put(opts, :blocking_user, user)
- Benchee.run(
- %{
- "public timeline with domain block" => fn opts ->
- ActivityPub.fetch_public_activities(opts)
- end
- }
- )
+ Benchee.run(%{
+ "public timeline with domain block" => fn ->
+ ActivityPub.fetch_public_activities(opts)
+ end
+ })
end
defp fetch_public_timeline(opts, title) when is_binary(title) do
first_page_last = ActivityPub.fetch_public_activities(opts) |> List.last()
second_page_last =
- ActivityPub.fetch_public_activities(Map.put(opts, "max_id", first_page_last.id))
+ ActivityPub.fetch_public_activities(Map.put(opts, :max_id, first_page_last.id))
|> List.last()
third_page_last =
- ActivityPub.fetch_public_activities(Map.put(opts, "max_id", second_page_last.id))
+ ActivityPub.fetch_public_activities(Map.put(opts, :max_id, second_page_last.id))
|> List.last()
forth_page_last =
- ActivityPub.fetch_public_activities(Map.put(opts, "max_id", third_page_last.id))
+ ActivityPub.fetch_public_activities(Map.put(opts, :max_id, third_page_last.id))
|> List.last()
Benchee.run(
@@ -303,17 +299,17 @@ defmodule Pleroma.LoadTesting.Fetcher do
},
inputs: %{
"1 page" => opts,
- "2 page" => Map.put(opts, "max_id", first_page_last.id),
- "3 page" => Map.put(opts, "max_id", second_page_last.id),
- "4 page" => Map.put(opts, "max_id", third_page_last.id),
- "5 page" => Map.put(opts, "max_id", forth_page_last.id)
+ "2 page" => Map.put(opts, :max_id, first_page_last.id),
+ "3 page" => Map.put(opts, :max_id, second_page_last.id),
+ "4 page" => Map.put(opts, :max_id, third_page_last.id),
+ "5 page" => Map.put(opts, :max_id, forth_page_last.id)
},
formatters: formatters()
)
end
defp opts_for_notifications do
- %{"count" => "20", "with_muted" => "true"}
+ %{count: "20", with_muted: true}
end
defp fetch_notifications(user) do
@@ -322,15 +318,15 @@ defmodule Pleroma.LoadTesting.Fetcher do
first_page_last = MastodonAPI.get_notifications(user, opts) |> List.last()
second_page_last =
- MastodonAPI.get_notifications(user, Map.put(opts, "max_id", first_page_last.id))
+ MastodonAPI.get_notifications(user, Map.put(opts, :max_id, first_page_last.id))
|> List.last()
third_page_last =
- MastodonAPI.get_notifications(user, Map.put(opts, "max_id", second_page_last.id))
+ MastodonAPI.get_notifications(user, Map.put(opts, :max_id, second_page_last.id))
|> List.last()
forth_page_last =
- MastodonAPI.get_notifications(user, Map.put(opts, "max_id", third_page_last.id))
+ MastodonAPI.get_notifications(user, Map.put(opts, :max_id, third_page_last.id))
|> List.last()
Benchee.run(
@@ -341,10 +337,10 @@ defmodule Pleroma.LoadTesting.Fetcher do
},
inputs: %{
"1 page" => opts,
- "2 page" => Map.put(opts, "max_id", first_page_last.id),
- "3 page" => Map.put(opts, "max_id", second_page_last.id),
- "4 page" => Map.put(opts, "max_id", third_page_last.id),
- "5 page" => Map.put(opts, "max_id", forth_page_last.id)
+ "2 page" => Map.put(opts, :max_id, first_page_last.id),
+ "3 page" => Map.put(opts, :max_id, second_page_last.id),
+ "4 page" => Map.put(opts, :max_id, third_page_last.id),
+ "5 page" => Map.put(opts, :max_id, forth_page_last.id)
},
formatters: formatters()
)
@@ -354,13 +350,13 @@ defmodule Pleroma.LoadTesting.Fetcher do
first_page_last = ActivityPub.fetch_favourites(user) |> List.last()
second_page_last =
- ActivityPub.fetch_favourites(user, %{"max_id" => first_page_last.id}) |> List.last()
+ ActivityPub.fetch_favourites(user, %{:max_id => first_page_last.id}) |> List.last()
third_page_last =
- ActivityPub.fetch_favourites(user, %{"max_id" => second_page_last.id}) |> List.last()
+ ActivityPub.fetch_favourites(user, %{:max_id => second_page_last.id}) |> List.last()
forth_page_last =
- ActivityPub.fetch_favourites(user, %{"max_id" => third_page_last.id}) |> List.last()
+ ActivityPub.fetch_favourites(user, %{:max_id => third_page_last.id}) |> List.last()
Benchee.run(
%{
@@ -370,10 +366,10 @@ defmodule Pleroma.LoadTesting.Fetcher do
},
inputs: %{
"1 page" => %{},
- "2 page" => %{"max_id" => first_page_last.id},
- "3 page" => %{"max_id" => second_page_last.id},
- "4 page" => %{"max_id" => third_page_last.id},
- "5 page" => %{"max_id" => forth_page_last.id}
+ "2 page" => %{:max_id => first_page_last.id},
+ "3 page" => %{:max_id => second_page_last.id},
+ "4 page" => %{:max_id => third_page_last.id},
+ "5 page" => %{:max_id => forth_page_last.id}
},
formatters: formatters()
)
@@ -381,8 +377,8 @@ defmodule Pleroma.LoadTesting.Fetcher do
defp opts_for_long_thread(user) do
%{
- "blocking_user" => user,
- "user" => user
+ blocking_user: user,
+ user: user
}
end
@@ -392,9 +388,9 @@ defmodule Pleroma.LoadTesting.Fetcher do
opts = opts_for_long_thread(user)
- private_input = {private.data["context"], Map.put(opts, "exclude_id", private.id)}
+ private_input = {private.data["context"], Map.put(opts, :exclude_id, private.id)}
- public_input = {public.data["context"], Map.put(opts, "exclude_id", public.id)}
+ public_input = {public.data["context"], Map.put(opts, :exclude_id, public.id)}
Benchee.run(
%{
@@ -514,13 +510,13 @@ defmodule Pleroma.LoadTesting.Fetcher do
public_context =
ActivityPub.fetch_activities_for_context(
public.data["context"],
- Map.put(fetch_opts, "exclude_id", public.id)
+ Map.put(fetch_opts, :exclude_id, public.id)
)
private_context =
ActivityPub.fetch_activities_for_context(
private.data["context"],
- Map.put(fetch_opts, "exclude_id", private.id)
+ Map.put(fetch_opts, :exclude_id, private.id)
)
Benchee.run(
@@ -551,14 +547,14 @@ defmodule Pleroma.LoadTesting.Fetcher do
end,
"Public timeline with reply filtering - following" => fn ->
public_params
- |> Map.put("reply_visibility", "following")
- |> Map.put("reply_filtering_user", user)
+ |> Map.put(:reply_visibility, "following")
+ |> Map.put(:reply_filtering_user, user)
|> ActivityPub.fetch_public_activities()
end,
"Public timeline with reply filtering - self" => fn ->
public_params
- |> Map.put("reply_visibility", "self")
- |> Map.put("reply_filtering_user", user)
+ |> Map.put(:reply_visibility, "self")
+ |> Map.put(:reply_filtering_user, user)
|> ActivityPub.fetch_public_activities()
end
},
@@ -577,16 +573,16 @@ defmodule Pleroma.LoadTesting.Fetcher do
"Home timeline with reply filtering - following" => fn ->
private_params =
private_params
- |> Map.put("reply_filtering_user", user)
- |> Map.put("reply_visibility", "following")
+ |> Map.put(:reply_filtering_user, user)
+ |> Map.put(:reply_visibility, "following")
ActivityPub.fetch_activities(recipients, private_params)
end,
"Home timeline with reply filtering - self" => fn ->
private_params =
private_params
- |> Map.put("reply_filtering_user", user)
- |> Map.put("reply_visibility", "self")
+ |> Map.put(:reply_filtering_user, user)
+ |> Map.put(:reply_visibility, "self")
ActivityPub.fetch_activities(recipients, private_params)
end
diff --git a/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex b/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
index 1162b2e06..c051335a5 100644
--- a/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
+++ b/benchmarks/mix/tasks/pleroma/benchmarks/tags.ex
@@ -100,14 +100,14 @@ defmodule Mix.Tasks.Pleroma.Benchmarks.Tags do
_activities =
params
- |> Map.put("type", "Create")
- |> Map.put("local_only", local_only)
- |> Map.put("blocking_user", user)
- |> Map.put("muting_user", user)
- |> Map.put("user", user)
- |> Map.put("tag", tags)
- |> Map.put("tag_all", tag_all)
- |> Map.put("tag_reject", tag_reject)
+ |> Map.put(:type, "Create")
+ |> Map.put(:local_only, local_only)
+ |> Map.put(:blocking_user, user)
+ |> Map.put(:muting_user, user)
+ |> Map.put(:user, user)
+ |> Map.put(:tag, tags)
+ |> Map.put(:tag_all, tag_all)
+ |> Map.put(:tag_reject, tag_reject)
|> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
end
end